Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / Write a program that reads the subtotal and the gratuity rate, and computes the gratuity and total

Write a program that reads the subtotal and the gratuity rate, and computes the gratuity and total

Computer Science

Write a program that reads the subtotal and the gratuity rate, and computes the gratuity and total. For example, if the user enters 10 for subtotal and 15% for gratuity rate, the program displays $1.5 as gratuity and $11.5 as total.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Answer:

public class Exercise2_5 {

public static void main(String args[]) {

// Read subtotal

java.util.Scanner input = new java.util.Scanner(System.in); System.out.print("Enter subtotal: ");

double subtotal = input.nextDouble();

// Read subtotal

System.out.print("Enter gratuity rate: "); double rate = input.nextDouble();

double gratuity = subtotal * rate / 100; double total = subtotal + gratuity;

System.out.println("Gratuity is " + gratuity); System.out.println("Total is " + total);

}

}

Related Questions