public class retailprice { public static void main(String[] args) { int choice,add,doneall,qproduct1,qproduct2,qproduct3,qproduct4,qproduct5,tprod1,tprod2,tprod3,tprod4,tprod5,done1,done2,done3,done4,done5,total; char cont; qproduct1=0; qproduct2=0; qproduct3=0; qproduct4=0; qproduct5=0; done1=0; done2=0; done3=0; done4=0; done5=0; doneall=0; total=0; cont='a'; do { do { System.out.println("\nEnter the number of the product:\nProduct 1\nProduct 2\nProduct 3\nProduct 4\nProduct 5\n"); choice=MyInput.readInt(); switch (choice) { case (1): { if (done1!=0) { System.out.println("\nYou already entered a quantity for Product 1, so press \na to choose another product, \nb to add to the previous value, or \nc to replace the existing value.\n"); cont=MyInput.readChar(); do { switch (cont) { case ('b'): { System.out.println("\nEnter the additional quantity\n"); add=MyInput.readInt(); qproduct1=qproduct1+add; tprod1=3*qproduct1; total=total+tprod1; System.out.println("\nThe revised total for Product 1 is $"+tprod1); System.out.println("\nPress a to continue entering data or t to find the total\n"); cont=MyInput.readChar(); break; } case ('c'): { System.out.println("\nEnter the new quantity for Product 1\n"); qproduct1=MyInput.readInt(); tprod1=3*qproduct1; total=total+tprod1; System.out.println("The total for Product 1 was $"+tprod1); System.out.println("Press a to continue entering data, or t to find the total"); cont=MyInput.readChar(); break; } default: { System.out.println("\nPlease choose a, b, or c\n"); cont=MyInput.readChar(); break; } } } while (cont=='c'); while (cont=='b'); } else if (done1==0) { System.out.println("\nEnter the quantity of Product "+choice+" sold\n"); qproduct1=MyInput.readInt(); tprod1=3*qproduct1; total=total+tprod1; done1=1; doneall=doneall+1; System.out.println("\nThe total for Product 1 was $"+tprod1); System.out.println("\nPress a to continue entering data, or t to find the total\n"); cont=MyInput.readChar(); } break; } case (2): { if (done2!=0) { System.out.println("\nYou already entered a quantity for Product 2, so press \na to choose another product, \nb to add to the previous value, or \nc to replace the existing value.\n"); cont=MyInput.readChar(); do { switch (cont) { case ('b'): { System.out.println("\nEnter the additional quantity\n"); add=MyInput.readInt(); qproduct2=qproduct2+add; tprod2=5*qproduct2; total=total+tprod2; System.out.println("\nThe revised total for Product 2 is $"+tprod2); System.out.println("\nPress a to continue entering data or t to find the total\n"); cont=MyInput.readChar(); break; } case ('c'): { System.out.println("Enter the new quantity for Product 2"); qproduct2=MyInput.readInt(); tprod2=5*qproduct2; total=total+tprod2; System.out.println("\nThe total for Product 2 was $"+tprod2); System.out.println("\nPress a to continue entering data, or t to find the total\n"); cont=MyInput.readChar(); break; } default: { System.out.println("\nPlease choose a, b, or c\n"); cont=MyInput.readChar(); break; } } } while (cont=='c'); while (cont=='b'); } else if (done2==0) { System.out.println("\nEnter the quantity of Product "+choice+" sold\n"); qproduct2=MyInput.readInt(); tprod2=5*qproduct2; total=total+tprod2; done2=1; doneall=doneall+1; System.out.println("\nThe total for Product 2 was $"+tprod2); System.out.println("\nPress a to continue entering data, or t to find the total\n"); cont=MyInput.readChar(); } break; } case (3): { if (done3!=0) { System.out.println("\nYou already entered a quantity for Product 3, so press \na to choose another product, \nb to add to the previous value, or \nc to replace the existing value.\n"); cont=MyInput.readChar(); do { switch (cont) { case ('b'): { System.out.println("\nEnter the additional quantity\n"); add=MyInput.readInt(); qproduct3=qproduct3+add; tprod3=10*qproduct3; total=total+tprod3; System.out.println("\nThe revised total for Product 3 is $"+tprod3); System.out.println("\nPress a to continue entering data or t to find the total\n"); cont=MyInput.readChar(); break; } case ('c'): { System.out.println("\nEnter the new quantity for Product 3\n"); qproduct3=MyInput.readInt(); tprod3=10*qproduct3; total=total+tprod3; System.out.println("The total for Product 3 was $"+tprod3); System.out.println("Press a to continue entering data, or t to find the total"); cont=MyInput.readChar(); break; } default: { System.out.println("\nPlease choose a, b, or c\n"); cont=MyInput.readChar(); break; } } } while (cont=='c'); while (cont=='b'); } else if (done3==0) { System.out.println("\nEnter the quantity of Product "+choice+" sold\n"); qproduct3=MyInput.readInt(); tprod3=10*qproduct3; total=total+tprod3; done3=1; doneall=doneall+1; System.out.println("\nThe total for Product 3 was $"+tprod3); System.out.println("\nPress a to continue entering data, or t to find the total\n"); cont=MyInput.readChar(); } break; } case (4): { if (done4!=0) { System.out.println("\nYou already entered a quantity for Product 4, so press \na to choose another product, \nb to add to the previous value, or \nc to replace the existing value.\n"); cont=MyInput.readChar(); do { switch (cont) { case ('b'): { System.out.println("\nEnter the additional quantity\n"); add=MyInput.readInt(); qproduct4=qproduct1+add; tprod4=9*qproduct4; total=total+tprod4; System.out.println("\nThe revised total for Product 4 is $"+tprod4); System.out.println("\nPress a to continue entering data or t to find the total\n"); cont=MyInput.readChar(); break; } case ('c'): { System.out.println("\nEnter the new quantity for Product 4\n"); qproduct4=MyInput.readInt(); tprod4=9*qproduct4; total=total+tprod4; System.out.println("The total for Product 4 was $"+tprod4); System.out.println("Press a to continue entering data, or t to find the total"); cont=MyInput.readChar(); break; } default: { System.out.println("\nPlease choose a, b, or c\n"); cont=MyInput.readChar(); break; } } } while (cont=='c'); while (cont=='b'); } else if (done4==0) { System.out.println("\nEnter the quantity of Product "+choice+" sold\n"); qproduct4=MyInput.readInt(); tprod4=9*qproduct4; total=total+tprod4; done4=1; doneall=doneall+1; System.out.println("\nThe total for Product 4 was $"+tprod4); System.out.println("\nPress a to continue entering data, or t to find the total\n"); cont=MyInput.readChar(); } break; } case (5): { if (done5!=0) { System.out.println("\nYou already entered a quantity for Product 5, so press \na to choose another product, \nb to add to the previous value, or \nc to replace the existing value.\n"); cont=MyInput.readChar(); do { switch (cont) { case ('b'): { System.out.println("\nEnter the additional quantity\n"); add=MyInput.readInt(); qproduct5=qproduct5+add; tprod5=7*qproduct5; total=total+tprod5; System.out.println("\nThe revised total for Product 5 is $"+tprod5); System.out.println("\nPress a to continue entering data or t to find the total\n"); cont=MyInput.readChar(); break; } case ('c'): { System.out.println("\nEnter the new quantity for Product 5\n"); qproduct5=MyInput.readInt(); tprod5=7*qproduct5; total=total+tprod5; System.out.println("The total for Product 5 was $"+tprod5); System.out.println("Press a to continue entering data, or t to find the total"); cont=MyInput.readChar(); break; } default: { System.out.println("\nPlease choose a, b, or c\n"); cont=MyInput.readChar(); break; } } } while (cont=='c'); while (cont=='b'); } else if (done5==0) { System.out.println("\nEnter the quantity of Product "+choice+" sold\n"); qproduct5=MyInput.readInt(); tprod5=7*qproduct5; total=total+tprod5; done5=1; doneall=doneall+1; System.out.println("\nThe total for Product 5 was $"+tprod5); System.out.println("\nPress a to continue entering data, or t to find the total\n"); cont=MyInput.readChar(); } break; } default: { cont=MyInput.readChar(); break; } } } while (cont=='a'); if (done1==0) System.out.println("You have not entered data for Product 1"); if (done2==0) System.out.println("You have not entered data for Product 2"); if (done3==0) System.out.println("You have not entered data for Product 3"); if (done4==0) System.out.println("You have not entered data for Product 4"); if (done5==0) System.out.println("You have not entered data for Product 5"); if (doneall!=5) System.out.println("Please enter the missing data."); } while (doneall<5); System.out.println("The total for products 1, 2, 3, 4, and 5 was $"+total+"\n\n\n\n\n\n\n"); } }