tip calculator

import java.util.Scanner; public class TipCalculator { public static void main(String[] args) { while (true) { Scanner sc = new Scanner(System.in); System.out.print("Please enter cost of meal"); double nextInt = sc.nextInt(); System.out.print("Now enter the percent you would like to tip"); double percent = sc.nextInt(); double tip = (nextInt * (percent/100)); double tipandmeal = ((tip) + nextInt); System.out.println("Total cost: " + tipandmeal); System.out.println("Please input how many people you would like to split the bill with"); int numberpeople = sc.nextInt(); double perperson = (tipandmeal/numberpeople); System.out.println("For " +numberpeople+ " people each person should pay: " +perperson); System.out.println("To calculate another tip, please press 1, or press 0 to close the program"); int last = sc.nextInt(); if (last != 1) { 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.