hi guys as you can probably tell im new here. and i really need help with a homework that i have for my class.
For starters I'm new in programming, so i dont really know much, and im taking java as my frist programming class, but i like it.
My homework is that i need to write a program that converts specific units for length, weight and volume. from the metric system to the US sytem and vice-versa; and before asking the user about the value to be converted, the program should ask the user what type of conversion to do.
After the convertion is completed the program should ask the user if he wants to make another calculation by replying "y" or "n". and also the program requires a minimun of 4 methods.
i have typed already my codes but they are separated, and i want to put them together, and i've been trying to look online, and havent really found a way that can fit. but like i said maybe it's just me.
here are my codes:
that should be my intro and how my methods would be separated and as you can see i hide my first try there. cause it didnt work. also i need to make my menu to work by pressing 1,2,3.
that's one example of one of my convertions and it does work, but i need help on how to put it inside my first code,
and that's all i have right now, and i would apreciate if you guys can help me, and if i'm asking for too much, then i'm sorry for doing so.
thanks in advance
For starters I'm new in programming, so i dont really know much, and im taking java as my frist programming class, but i like it.
My homework is that i need to write a program that converts specific units for length, weight and volume. from the metric system to the US sytem and vice-versa; and before asking the user about the value to be converted, the program should ask the user what type of conversion to do.
After the convertion is completed the program should ask the user if he wants to make another calculation by replying "y" or "n". and also the program requires a minimun of 4 methods.
i have typed already my codes but they are separated, and i want to put them together, and i've been trying to look online, and havent really found a way that can fit. but like i said maybe it's just me.
here are my codes:
import java.util.Scanner; public class Homework1 { public static void main(String[] args) { Welcome(); Choices(); int a; } /*{ //System.out.println("Welcome to the unit converter please choose one of the following:"); Scanner in = new Scanner(System.in); double lenght; double weight; double volume; (length = 1); (weight = 2) (volume = 3); System.out.println( "1. Convert lenght"); System.out.println( "2. Convert weight"); System.out.println( "3. Convert volume"); }*/ static void Welcome() { System.out.println("Welcome to the Unit Converter, please choose one of the following"); /*System.out.println( "1. Convert lenght"); System.out.println( "2. Convert weight"); System.out.println( "3. Convert volume");*/ } static void Choices() { Scanner in = new Scanner(System.in); System.out.println( "1. Convert lenght"); System.out.println( "2. Convert weight"); System.out.println( "3. Convert volume"); int a; a=in.nextInt(); } static void Weight() { } static void Volume() { }
that should be my intro and how my methods would be separated and as you can see i hide my first try there. cause it didnt work. also i need to make my menu to work by pressing 1,2,3.
import java.util.Scanner; public class converter { public static void main(String[] args) { double pounds; double kilograms; Scanner keyboard = new Scanner(System.in); System.out.print("Enter pounds: "); pounds = keyboard.nextInt(); kilograms = (kilograms(pounds)); System.out.println(pounds + " Pounds is " + kilograms +" Kilograms"); } public static double kilograms(double temp) { return (temp/2.2046);
that's one example of one of my convertions and it does work, but i need help on how to put it inside my first code,
and that's all i have right now, and i would apreciate if you guys can help me, and if i'm asking for too much, then i'm sorry for doing so.
thanks in advance