Answer:
- import java.util.Scanner;
- public class Main {
-
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.print("Enter meal total: $");
- double meal = input.nextDouble();
- double finalAmount = meal + meal *0.09;
-
- if(finalAmount * 0.15 > 8){
- finalAmount = finalAmount + 8;
- }else{
- finalAmount = finalAmount + finalAmount * 0.15;
- }
- System.out.println("Final amount: $" + finalAmount);
- }
- }
Step-by-step 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).