Question
import java.util.Scanner;// import the Scanner public class BestPurchaseOnline { public static void main(String[] args) { Scanner input = new Scanner(System.in);// create the Scanner //Declare the
import java.util.Scanner;// import the Scanner public class BestPurchaseOnline { public static void main(String[] args) { Scanner input = new Scanner(System.in);// create the Scanner //Declare the variables String sName = "";//variable for customer name int nItem = 0; int nPricePerItem = 0; double dSalesTax = 0; int nCount = 0; int nItemOrder = 0; int nSumItem = 0; int nTotalAmountDue = 0; int nPriceOfItem = 0; //Declare Constant final int SENTINEL = 10; // value to end number of item System.out.print("Please enter your name: "+sName); sName = input.nextLine(); System.out.println(" BEST PURCHASE PRODUCTS"); System.out.println("1. Smartphone $249"); System.out.println("2. Smartphone case $39"); System.out.println("3. PC Laptop $1149"); System.out.println("4. Tablet $349"); System.out.println("5. Tablet case $49"); System.out.println("6. eReader $119"); System.out.println("7. PC Desktop $899"); System.out.println("8. LED Monitor $299"); System.out.println("9. Laser Printer $399"); System.out.println("10.Complete my order"); System.out.println("Please select an item from the menu above: "); nItem = input.nextInt(); while(nItem!=SENTINEL){ nCount++; // nCount = nCount + 1; nSumItem = nSumItem + nItem; } System.out.println("Thank you for ordering with Best Purchase, "+sName); nItemOrder = (nCount); System.out.println("Total items ordered: "+nItemOrder); System.out.println("Price of items ordered:$ "+ nSumItem); dSalesTax = (0.65 * nPricePerItem); System.out.println("Sales Tax:$ "); System.out.println("Total amount due:$ ");
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started