In Java please,
A friend of yours would like a program that receives an input as a meal total, then add 9% tax, and finally adds 15% tip (on the total including tax). Your friend is cheap so if the total tip added is more than $8, then they will just leave $8 (they would like that condition in the program). The program should output the final amount your friend should pay.

Answer :

Answer:

  1. import java.util.Scanner;
  2. public class Main {
  3.    public static void main(String[] args) {
  4.        Scanner input = new Scanner(System.in);
  5.        System.out.print("Enter meal total: $");
  6.        double meal = input.nextDouble();
  7.        double finalAmount = meal + meal *0.09;
  8.        if(finalAmount * 0.15 > 8){
  9.            finalAmount = finalAmount + 8;
  10.        }else{
  11.            finalAmount = finalAmount + finalAmount * 0.15;
  12.        }
  13.        System.out.println("Final amount: $" + finalAmount);
  14.    }
  15. }

Explanation:

Firstly, create a Scanner object and print user to input total meal (Line 5-7). Next, add the 9% tax to the meal total (Line 8). Use an if statement to check if the finalAmount multiplied by the 15% of tips is bigger than 8 (Line 10), if so, only add 8 to the final amount (Line 11). If not, add 15% tips to final amount (Line 12). At last, print out the final amount (Line 15).

Other Questions