You are on page 1of 2

import javax.swing.

JOptionPane;
public class CSOBJECT_EXER2 {
public static void main ( String args[] )
{
String jchoice, jfnum, jsnum;
int choice, num1, num2, sum, foo = 0;
do{
jchoice = JOptionPane.showInputDialog ("Enter choice \n
" + "1. Mass (Carats to Milligrams) \n " + "2. Volume (Cubic Foot to Cubic Inch)
\n " + "3. Weight (Ounce to Stone)\n " + "4. Exit Program ");
choice = Integer.parseInt (jchoice);
switch(choice){
case 1:
jfnum = JOptionPane.showInputDialog ( "E
nter value (in Carats)" );
num1 = Integer.parseInt(jfnum);
sum = num1 * 200;
JOptionPane.showMessageDialog(null, num1
+ " Carat is equal to " + sum + " Milligrams");

break;
case 2:
jfnum = JOptionPane.showInputDialog ( "E
nter value (in Cubic Foot)" );
num1 = Integer.parseInt(jfnum);
sum = num1 * 1728;
JOptionPane.showMessageDialog(null, num1
+ " Cubic Foot is equal to " + sum + " Cubic Inch");
break;
case 3:
jfnum = JOptionPane.showInputDialog ( "E
nter value (in Ounces)" );
num1 = Integer.parseInt(jfnum);
double temp = num1 * 0.00446429;
JOptionPane.showMessageDialog(null, num1
+ " Ounce is equal to " + temp + " Stones");
break;
case 4:
JOptionPane.showMessageDialog(null, "Exi
ting Program!!!!, Thank You!!!");

break;
default:
JOptionPane.showMessageDialog(null, "Choice out
of range, Try Again!!!");
}
}while (choice != 4);
System.exit ( 0 );
}
}

You might also like