SHARE
TWEET

Untitled

a guest Sep 20th, 2019 80 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class tipcalc {
  4.    
  5.     public static void main (String[]args) {
  6.        
  7.         Scanner sc = new Scanner (System.in);
  8.        
  9.         int bill;
  10.         double tip;
  11.         double total;
  12.         int response = 1;
  13.         int ppl;
  14.         double priceperperson;
  15.        
  16.         while(response == 1) {
  17.         System.out.println("How much was your bill?");
  18.        
  19.         bill = sc.nextInt();
  20.        
  21.         System.out.println("What percent would you like to tip?");
  22.        
  23.         tip = sc.nextInt();
  24.        
  25.         tip = (tip/100)*bill;
  26.        
  27.         total = bill+tip;
  28.        
  29.         System.out.println("How many people are splitting the bill?");
  30.         ppl=sc.nextInt();
  31.         priceperperson = total/ppl;
  32.        
  33.         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);
  34.        
  35.         System.out.println("Would you like to calculate another tip? 1 for yes, 2 for no");
  36.        
  37.         response = sc.nextInt();
  38.                
  39.                 if(response == 1) {response = 1;}
  40.                 else {response = 0;}
  41.                
  42.        
  43.         }
  44.     }
  45.  
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top