Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class ExerciseNumber5 {
- static Scanner console = new Scanner(System.in);
- public static void main(String[]args)
- {
- double numsold,code,tps,price;
- int A,B;
- String choices;
- 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(" Enter the product code: ");
- code = console. nextDouble();
- System.out.println("Enter the number of items sold: ");
- numsold = console. nextDouble();
- System.out.println("Choose what transaction you prefer");
- System.out.println("A. Determine the retail price of each product");
- System.out.println("B. Calculate the total price sold");
- choices =console. nextLine();
- switch (choices) {
- case "A":
- if (code == 1) {
- System.out.println("The retail price is: 123.45");
- }
- if (code == 2) {
- System.out.println("The retail price is: 450.95");
- }
- if (code == 3) {
- System.out.println("The retail price is: 1200.50");
- }
- if (code == 4) {
- System.out.println("The retail price is: 670.99");
- }
- if (code == 5) {
- System.out.println("The retail price is: 999.90");
- }
- else {
- System.out.println("None of the choices");
- }
- case "B":
- tps= numsold*(price=code);
- System.out.println("The total is:"+tps);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment