Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class TipCalulator here.
- *
- * @Arjun Bhamra
- * @9/6/19
- */
- import java.util.Scanner;
- public class TipCalulator
- {
- public static void main(String[] args){
- TipCalculate();
- Scanner qp = new Scanner(System.in);
- System.out.println("Press 1 to use again or 2 to exit.");
- int choice=qp.nextInt();
- if(choice==1){
- TipCalculate();
- } else if(choice==2){
- System.out.println("Thank you for shopping with us!");
- }
- }
- public static void TipCalculate(){
- Scanner sc = new Scanner(System.in);
- System.out.println("What is the cost of the bill? Keep to two significant figures!");
- double cost = sc.nextDouble();
- Scanner kb = new Scanner(System.in);
- System.out.println("What percentage of the bill would you like to tip?");
- double percentage = kb.nextDouble();
- double tip = ((percentage/100)*cost);
- double totalCost = (cost+tip);
- System.out.println("By choosing to tip "+percentage+ "%, you are tipping $" + tip);
- System.out.println("Your total cost for this meal is $" + totalCost);
- Scanner ab = new Scanner(System.in);
- System.out.println("How many people will be splitting the bill?");
- int people = ab.nextInt();
- double split = (totalCost/people);
- System.out.println("Each person will have to pay $" + split);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement