Shopping Cart /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package practiceshop; import java.text.*; /** * * @author david johnson */ public class Main { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here //define double newPrice = 0; int numUnits = 0; double totalValue = 0; String choice = "yes"; //while loop while (choice.equalsIgnoreCase("yes")) { System.out.print("Please enter the price of the new item: "); newPrice = MyInput.readDouble(); System.out.print("Pleae enter the units of the item: "); numUnits = MyInput.readInt();
double newTotal = newPrice * numUnits; totalValue = newTotal + totalValue; System.out.println("Continue? (yes/no): "); choice = MyInput.readString(); }//while loop ends //currency
NumberFormat currency = NumberFormat.getCurrencyInstance(); //process double taxRate = 8.5 / 100; double totalPrice = totalValue * (1 + taxRate); //output System.out.println("The new total is: " + currency.format(totalPrice)); } }