tipcalc

/** * @author spoopy * @v 1.0 * tipcalc */ import java.util.*; public class TipCalc { public static void main (String args[]) { while (true) { Scanner tipscan = new Scanner(System.in); //start tipcalc code System.out.println("What percent do you want to tip your waiter?"); double whatTip = tipscan.nextDouble(); System.out.println("What was the cost of your food?"); double bill = tipscan.nextDouble(); double theTip = bill * (whatTip/100.0); double total = bill + theTip; System.out.println("The amount of the tip comes out to be: $" + theTip); System.out.println("The total amount paid comes out to be: $" + total); System.out.println("How many people do you have?"); //start people code double numPeople = tipscan.nextDouble(); double eachPerson = total/numPeople; System.out.println("Each person must pay $" + eachPerson); Scanner recalc = new Scanner(System.in); //begin rerun code System.out.println("Do you need another tip calculated? Type newtip to recalculate."); String answer = recalc.nextLine(); if (!answer.equals("new")) { break; } } } }

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.