hi every one i'm new member and i'm beginner in java
i have a problem in me code and i don't know how to deal with it
this is the question
In this project, write a Java program that will convert an input metric to a corresponding value in the International System of Units. Input metric will be in Yards, Inches, Miles, and Pounds. The converted metric should be converted as follows:
Table 1:
Input Metric
Output Metric
Yards
Meters
Inches
Centimeters
Miles
Kilometers
Pounds
Kilogram
The program should display a Menu for the user to choose from the above metric. The menu is shown in the figure below.
Welcome to Multi conversion System
Press c for Inches to Centimeters
Press m for Yards to Meters
Press k for Miles to Kilometers
Press g for Pounds to Kilograms
The user has to enter c, m, k, or g. Next, the user will enter a value for the input metric which the program will convert to the specified unit from table 1. The output of the program should be the converted metric value. In addition, consider the following scenarios in the output:
1. If the user inputs a character that is not recognized (NOT c, m, k, or g), then the program prints “Wrong Selection!”, and exits.
2. If the user inputs a value less than zero for a metric, the program will display a message that states “Cannot convert a negative value!”
3. After displaying the converted metric value (if input value is not negative), the program should also display the range of the converted value according to the following rules:
a. If converted value is less than 20, print “Less than 20.”
b. If converted value is less than 50, print “Less than 50.”
c. If converted value is equal 50, print “Equal 50”.
d. If converted value is greater than 50, print “Greater than 50.”
Hint 1: To read a character using a Scanner input, use the following statement:
char c = input.nextLine().charAt(0);
Hint 2: To convert a metric use the following formulas:
Centimeters = 2.54 * inches
Meters = 0.9144 * Yards
Kilometers = 1.60934 * Miles
Kilograms = 0.453592 * Pounds
Note: Submit only the source code. For example: IA_1110348_P2.java
Sample Program Run #1:
Welcome to Multi conversion System
Press c for Inches to Centimeters
Press m for Yards to Meters
Press k for Miles to Kilometers
Press g for Pounds to Kilograms
k
Enter a value in Miles: 10
Your 10.0 Miles are 16.0934 Kilometers. Less than 20.
Sample Program Run #2:
Welcome to Multi conversion System
Press c for Inches to Centimeters
Press m for Yards to Meters
Press k for Miles to Kilometers
Press g for Pounds to Kilograms
y
Wrong Selection!
Sample Program Run #3:
Welcome to Multi conversion System
Press c for Inches to Centimeters
Press m for Yards to Meters
Press k for Miles to Kilometers
Press g for Pounds to Kilograms
g
Enter a value in Miles: -20
Cannot convert a negative value!
Sample Program Run #4:
Welcome to Multi conversion System
Press c for Inches to Centimeters
Press m for Yards to Meters
Press k for Miles to Kilometers
Press g for Pounds to Kilograms
c
Enter a value in Inches: 100
Your 100.0 Inches are 254.0 Centimeters. Greater than 50.
and i have try many times to solve it and every time i failed
please help meimport java.util.Scanner; import javax.swing.JOptionPane; /** * * @author Mac */ public class EA_1211835_P2 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here double yardes,inches,miles,pounds,meters,centimeters,kilogram,kilometers; char c,m,k,g; String x; Scanner in = new Scanner(System.in); x=JOptionPane.showInputDialog(null, "please press c for centimeters , g for kilogram , k for kilometers , m for meters "); c=in.nextLine().charAt(0); m=in.nextLine().charAt(0); k=in.nextLine().charAt(0); g=in.nextLine().charAt(0); if (c<20) { c=inches*2.45; } } }