Grasshopper Technologies |
Java Fun! - Chapter 6 - Taximport java.util.Scanner; public class JavaFun06aTax { public static void main(String[] args) { Scanner ob=new Scanner(System.in); double price = 100; System.out.println("I will figure out how much tax will be charged on an item"); System.out.println(" and add it to your purchase. Just input the price."); System.out.println("Input '0' to stop."); while (price != 0.0) { System.out.print("\nPrice of Item? "); price=ob.nextDouble(); if (price != 0.0) { price = price * .1025 + price; System.out.printf("Your item will cost $%.2f", price ); } } } } run: I will figure out how much tax will be charged on an item and add it to your purchase. Just input the price. Input '0' to stop. Price of Item? 30 Your item will cost $33.08 Price of Item? 40 Your item will cost $44.10 Price of Item? 0 BUILD SUCCESSFUL (total time: 8 seconds) |