Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class java2 {
- static Scanner console = new Scanner(System.in);
- public static void main(String[]args)
- {
- int quantity,pc,total;
- double price = 0;
- System.out.println("Product code Price");
- System.out.println(" 1 123.45");
- System.out.println(" 2 450.95");
- System.out.println(" 3 1200.50");
- System.out.println(" 4 670.99");
- System.out.println(" 5 999.90");
- System.out.println("Input Product code:");
- pc= console.nextInt();
- System.out.println("Input the Quantity:");
- quantity= console.nextInt();
- switch(pc)
- {
- case 1: price=123.45;
- break;
- case 2: price=450.95;
- break;
- case 3: price=1200.50;
- break;
- case 4: price=670.99;
- break;
- case 5: price=999.90;
- break;
- default : System.out.println("Invalid Product code!");
- }
- total= (int) (price * quantity);
- System.out.println("Total:"+total);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment