This Java program allows a user to calculate the total charge for ordering garage door openers. It prompts the user to input the quantity ordered, unit price, and contractor credit. It then calls a method to calculate the order total by applying a 15% discount, 9.5% tax, and subtracting the credit amount. The total charge is printed and the user is prompted to calculate another order or quit.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
28 views
Java
This Java program allows a user to calculate the total charge for ordering garage door openers. It prompts the user to input the quantity ordered, unit price, and contractor credit. It then calls a method to calculate the order total by applying a 15% discount, 9.5% tax, and subtracting the credit amount. The total charge is printed and the user is prompted to calculate another order or quit.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
import java.util.
Scanner;
public class GarageDoorOpener {
public static void main(String[] args) { Scanner input = new Scanner(System.in); String choice = "Y";
while (choice.equalsIgnoreCase("Y")) { int quantity = 0; double unitPrice = 0.0; double credit = 0.0;
// Ask user for inputs
System.out.print("Enter the quantity of garage door openers ordered: "); if (input.hasNextInt()) { quantity = input.nextInt(); } else { System.out.println("Invalid input. Please enter a valid integer."); input.next(); continue; }
System.out.print("Enter the unit price of the garage door openers: ");
if (input.hasNextDouble()) { unitPrice = input.nextDouble(); } else { System.out.println("Invalid input. Please enter a valid decimal number."); input.next(); continue; }
System.out.print("Enter the credit that the contractor has with the
company: "); if (input.hasNextDouble()) { credit = input.nextDouble(); } else { System.out.println("Invalid input. Please enter a valid decimal number."); input.next(); continue; }