Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Robert Corrato
- //9/9/19 APCSA
- public class TipCalc{
- public static void main(String[] args) {
- int twentyPercent; // must be interger (whole number)
- double bill;
- double tip;
- double subtotal;
- int tries;
- Scanner sc = new Scanner(System.in);
- //$ shows up
- //Looked this up, thought it would be cool.
- System.out.println("What is the value of your bill?");
- bill = sc.nextDouble();
- System.out.println("You are going to tip 20%. Don't be stingy."); // Enter tip percentage
- twentyPercent = sc.nextInt();
- tip = (bill + tip) / 100; //the tip
- subtotal = bill + tip; // This calculates your total
- System.out.println("Tip Amount " + fmt1.format(tip));
- System.out.println("Total including Tip " + fmt1.format(subtotal));
- System.out.println("Would you like to split the tip? Yes or no?");
- String answer = sc.nextLine();
- if (answer == "yes"){
- System.out.println("How many people will you split the tip with?");
- int split = sc.nextInt();
- System.out.println("The new total for each person will be " + subtotal/split);
- }else{
- System.out.println("Wow, you are a nice person, or a very lonely person.");
- System.out.println("Would you like to calculate another tip? 1 for yes");
- int playAgain = sc.nextInt();
- if (playAgain != 1){
- playAgain = true;
- }else{
- tries = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement