Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class TipCalculator {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String calc = "yes";
- while (calc.equals ("yes")) {
- System.out.println("Enter Total Amount of Bill");
- Double tot = (double) sc.nextDouble();
- System.out.println("Enter percent you would like to tip");
- Double per = (sc.nextDouble() * .01);
- double tip = (per * tot);
- System.out.println("Amount of Tip:" + tip);
- System.out.println("Total Bill:" + (tip + tot));
- System.out.println("How many people are splitting the bill?");
- int ppl = sc.nextInt();
- double splt = ((tip + tot) / ppl);
- System.out.println("Each persons total is: $" + splt);
- sc.nextLine();
- System.out.println("Would you like to run again?");
- calc = sc.nextLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement