Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class tipcalc {
- public static void main (String[]args) {
- Scanner sc = new Scanner (System.in);
- int bill;
- double tip;
- double total;
- int response = 1;
- int ppl;
- double priceperperson;
- while(response == 1) {
- System.out.println("How much was your bill?");
- bill = sc.nextInt();
- System.out.println("What percent would you like to tip?");
- tip = sc.nextInt();
- tip = (tip/bill)*bill;
- total = bill+tip;
- System.out.println("How many people are splitting the bill?");
- ppl=sc.nextInt();
- priceperperson = total/ppl;
- System.out.println("The cost of your food was: $" + bill + "\nThe tip you chose to give was: $" + tip + "\nYour total is: $" + total + "\nThe price per person is: $" + priceperperson);
- System.out.println("Would you like to calculate another tip? 1 for yes, 2 for no");
- response = sc.nextInt();
- if(response == 1) {response = 1;}
- else {response = 0;}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement