Language = Java
Create a program to receive book prices until a sentinel value is entered. (Be sure to tell your user what the sentinel value is so they can type it to indicate they are finished with entering input.) After the sentinel value is entered, compute the total book order total and return the following to the user.
As book prices are entered, you'll need to have some way to capture the number of books they ordered and the running subtotal for use in the total book order 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. Output a receipt formatted as the following:
|
Enter the book price and press enter or type 999 when you are finished added books: 12.22 Enter another book price and press enter or type 999 when you are finished added books: 12.00 Enter another book price and press enter or type 999 when you are finished added books: 13.33 Enter another book price and press enter or type 999 when you are finished added books: 999 Number of books purchased: 3 Book Subtotal: $37.55 Tax: $2.07 Shipping: $4.50 ------------------------ Order Total: $44.12 |
IMPORTANT TESTING NOTE: Double check your math to make sure your sentinel value isn't being added into the book total and that you don't end up with an extra book in the number of books purchased. You can prevent that by setting up your loop correctly. If you are subtracting 1 from the book count or subtracting the sentinel value, you do not have your loop set up correctly.
Program Screen Shot:

Sample Output:

Program Code to Copy:
import java.util.Scanner;
public class BooksOrder {
public static void main(String[] args) {
Scanner input = new
Scanner(System.in);
double price;
// initialize to zero for
cumulative sum operations
int numberOfBooks = 0;
double subTotal = 0;
do {
System.out.print("Enter the book price and press enter" +
"or type 999 when you are finished
added books:");
price =
input.nextDouble();
if(price!=999) {
// check exit status first before computing anything
numberOfBooks += 1;
subTotal += price;
}
}while(price!=999); // exit
loop
// compute final results
double tax =
subTotal*5.5/100;
double shippingCharge =
numberOfBooks*1.5;
double orderTotal = subTotal + tax
+ shippingCharge;
// show receipt
System.out.println("Number of books
purchased: "+ numberOfBooks);
System.out.println("Book Subtotal:
$"+String.format("%.2f",subTotal));
System.out.println("Tax: $" +
String.format("%.2f",tax));
System.out.println("Shipping: $" +
String.format("%.2f",shippingCharge));
System.out.println("-------------------------------");
System.out.println("\nOrder Total:
$" + String.format("%.2f",orderTotal));
}
}
------------------------------------------------------------------------------
COMMENT DOWN FOR ANY QUERY RELATED TO THIS ANSWER,
IF YOU'RE SATISFIED, GIVE A THUMBS UP
~yc~
Language = Java Create a program to receive book prices until a sentinel value is entered....
Write a C++ program that will calculate the total amount of money for book sales at an online store. For each sale, your program should ask the number of books sold and then the price for each book and the shipping method (‘S’ for standard shipping and ‘E’ for expedited shipping). The program will produce a bill showing the subtotal, the sales tax, the discount, the shipping charge, and the final total for the sale. The program will continue processing...
Modify your Online Book Order program from week 4 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 and the number of books to pass to your method. No changes should be needed to your method or parameters. Output a receipt formatted as the following: Enter the number of books purchased: 4 Enter the book...
Language = JAVA Create a new Java file called PhotoBillingYourLastName with a public static void main. Create three overloaded computePhotoBill() methods for Shutterfly. When computePhotoBill() receives a single double parameter, it represents the price of one photo book ordered. Add 6% tax and return the total due as a double. When computePhotoBill() received two parameters, they represent the price of a photo book and the quantity ordered (int). Multiply the two values, add 6% tax and return the total due....
Modify your Online Book Order program from week 5 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 and the number of books to pass to your method. No changes should be needed to your method or parameters. Output a receipt formatted as the following: Enter the number of books purchased: 4 Enter the book...
Create an order entry screen program in C# to give a total for an individual pizza order. The Pizza order should have radio buttons for small $7, medium $9, and large $12 choices for the pizza. There should be a checkbox for drink (where a drink is $2 added if it is checked and nothing added if it is not checked. Include a textbox for the customer’s name. Have a button to calculate the subtotal (pizza choice and whether there...
Write a C++ program that asks for the following information about a book order from the console: • Title • Author • ISBN (hint: careful about what data type to use - validate 9 or 13 characters) • Price (validate number < 400) • Quantity (number of books to purchase – validate > 0 and < 100) • Fiction/Non-Fiction (‘N’ or ‘F’ - validate) • Genre (‘R’ romance, ‘D’ drama, ‘M’ mystery – validate) Make use of the following data...
eclipse java Oxygen
Design a self-service fast food menu. Name your class FastFood. Create a test class based on the examples from chapter 4. Create a program to do the following. When you set up the program, save the java file to a folder named Chapter 04 Program. Console Welcome to the fast food order menu How may I help you Please place your order: НННН Please place your order Your order Your subtotal: $e.00 $e.00 Continue? (y/n): Y Please...
This is JAVA language Create a .java class called MoreArrayFun.java with only a main method. This program will use the ArrayManager class. The final version of the program is described below, but initially use it to test your ArrayManager class as you write it. Complete the ArrayManager class as specified below: The class will have exactly two instance variables: An array of integers A count of the number of elements currently in the array The class will have...
Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...
Overview JAVA LANGUAGE PROBLEM: The owner of a restaurant wants a program to manage online orders that come in. This program will require multiple classes. Summary class, customer class, order class and the driver class. Summary class This class will keep track of the cost of the order and output a summary, which includes the total for the order. The methods in this class are static. There are no instance variables, and instead uses an Order object that is passed...