Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Maya Gambhir
- * B block AP CS A
- * Tip Calculator program
- */
- import java.util.*;
- public class TipCalculator
- {
- public static void main (String[]args) {
- Scanner sc=new Scanner(System.in);
- int again=1;
- while (again==1){
- System.out.println("How much is your bill? ");
- double bill=sc.nextDouble();
- System.out.println("\nWhat percent would you like to tip? ");
- int percent=sc.nextInt();
- //calculate tip
- double tip=(((double)percent)/100)*bill;
- double totalBill=bill+tip;
- System.out.println("\nTotal tip is $"+tip);
- System.out.println("\nTotal bill is $"+totalBill);
- //split
- System.out.println("\nHow many people would you like to split \nthe bill with?");
- int split=sc.nextInt();
- double splitBill=totalBill/split;
- System.out.println("\nEach person pays $"+splitBill);
- //again?
- System.out.println("\nPress 1 to calculate another tip");
- System.out.println("Press 2 to quit");
- again=sc.nextInt();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement