I am a new member.
I got stuck using Switch in java. Could someone help me?
This is my code:
Thanks
[CODE=java]import java.util.Scann er;
public class MailOrder {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );//declare Scanner object
int productID=0;//productID
double totalValue = 0; //total value of the order
double Product1 = 2.98;
double Product2 = 4.50;
double Product3 = 6.87;
System.out.prin tln("Enter product number (1-3): " );
productID = input.nextInt() ; //read the product ID
// determine the number sold of the item
System.out.prin tln( "Enter quantity ordered: " );
int quantity = input.nextInt() ;
//please complete the switch statement
switch (productID)
{
case 1:
quantity += quantity;
break;
case 2:
quantity += quantity;
break;
case 3:
quantity += quantity;
break;
} // end switch
if (totalValue !=0)
System.out.prin tln ("Total Valude of this order is "+ totalValue);
}
}[/CODE]
I got stuck using Switch in java. Could someone help me?
This is my code:
Thanks
[CODE=java]import java.util.Scann er;
public class MailOrder {
public static void main(String[] args) {
Scanner input = new Scanner( System.in );//declare Scanner object
int productID=0;//productID
double totalValue = 0; //total value of the order
double Product1 = 2.98;
double Product2 = 4.50;
double Product3 = 6.87;
System.out.prin tln("Enter product number (1-3): " );
productID = input.nextInt() ; //read the product ID
// determine the number sold of the item
System.out.prin tln( "Enter quantity ordered: " );
int quantity = input.nextInt() ;
//please complete the switch statement
switch (productID)
{
case 1:
quantity += quantity;
break;
case 2:
quantity += quantity;
break;
case 3:
quantity += quantity;
break;
} // end switch
if (totalValue !=0)
System.out.prin tln ("Total Valude of this order is "+ totalValue);
}
}[/CODE]
Comment