?
2009-05-27 18:45:11 UTC
public class if_test
{
public static void main (String Args[])
{
double new_value=0.0;
double orig_value;
String new_unit;
String orig_unit;
Scanner scan = new Scanner (System.in);
System.out.print ("Original Unit:");
orig_unit=scan.nextLine ();
System.out.print ("New Unit:");
new_unit=scan.nextLine ();
System.out.print ("Original Value:");
orig_value=scan.nextDouble ();
if (orig_unit=="AUD")
{ if (new_unit=="AUD")
new_value=orig_value;
if (new_unit=="HKD")
new_value=(orig_value*0.837676/0.161422);
if (new_unit=="USD")
new_value=(orig_value*0.837676/1.252920);
}
if (orig_unit=="CAD")
{ if (new_unit=="CAD")
new_value=(orig_value);
if (new_unit=="HKD")
new_value=(orig_value*(1.0/0.161422));
if (new_unit=="AUD")
new_value=(orig_value*(1.0/0.837676));
if (new_unit=="USD")
new_value=(orig_value*(1.0/1.252920));
}
System.out.println ("New Value is: " + new_value);
}
}
Your suppose to enter one of the following units: AUD, HKD, CAD, and USD. Then you ae supose to enter the unit you want to convert to and it makes the conversions.....