Tip Calculator

//Sebastian Garrubbo //9/17/17 import java.text.DecimalFormat; import java.util.Scanner; public class TipCalculator { //initiation of static public static void main(String[] args) { Scanner scan = new Scanner(System.in);//scans DecimalFormat format = new DecimalFormat("00.00");//decimals boolean goAgain = true; while(goAgain){ //loop option System.out.println("\nYou have just finished your meal at Mr.Lee's Noodle Store."); System.out.println("\nHow much did you pay for your meal? $: "); double bill = scan.nextDouble(); try { } catch (Exception $) { } System.out.println("\nYou payed $" + bill); System.out.println("\nWhat percentage of the bill would you like to tip to Mr.Lee?"); double percentage = scan.nextInt(); double tip = bill * percentage/100; double total = tip + bill; System.out.println("\nYou tipped Mr.Lee $" + tip); System.out.println("\nYour total payment is $" + total); System.out.println("\nTo have another yummy meal press 1, any other number to exit"); int cont = scan.nextInt(); if(cont != 1) //! means not = to 1 goAgain = false; }//end of while }//end of static }//end of class

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.