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.
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.
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.
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; }