I need to modify the program to prompt the users for the number of books they are purchasing.Using a for loop, prompt the user for the cost of each...
View the step-by-step solution to:

Question

I need to modify the program to prompt the users

for the number of books they are purchasing. Using a for loop, prompt the user for the cost of each book and store it into a subtotal. Use the subtotal for the total book price. Compute the tax and shipping as usual (tax is 5.5 percent of the total book price & shipping charge is $1.50 per book). The price of the order is still the sum of the total book price, the tax, and the shipping charge.


import java.util.Scanner;

public class BookOrderReid {

 public static void main(String[] args)

 {

 Scanner in = new Scanner(System.in);

 

 //Test Data #1

 System.out.print("Enter the number of books purchased: ");

 int numberBook = in.nextInt();

 

 System.out.print("nEnter the book order subtotal: ");

 double Subtotal = in.nextDouble();

 double Tax;

 double Shipping;

 double Total;

 

 Tax = (Subtotal * 0.055);

 Shipping = (numberBook * 1.5);

 Total = (Subtotal + Tax + Shipping);

 

 System.out.println("nNumber of books purchased: " + numberBook);

 System.out.println("nBook subtotal: $" + Subtotal);

 System.out.printf("nTax: $%5.2f" ,Tax);

 System.out.printf("nnShipping: $%5.2f" , Shipping );

 System.out.println("nn-------------------------");

 System.out.printf("nOrder Total: $%5.2f" , Total);

 

 

 }

}

Top Answer

View the full answer
Capture.PNG

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question