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...
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...
In this lab, you will create a program to help travelers book flights and hotel stays that will behave like an online booking website. The description of the flights and hotel stays will be stored in two separate String arrays. In addition, two separate arrays of type double will be used to store the prices corresponding to each description. You will create the arrays and populate them with data at the beginning of your program. This is how the arrays...
Project overview: Create a java graphics program that displays an order menu and bill from a Sandwich shop, or any other establishment you prefer. In this program the design is left up to the programmer however good object oriented design is required. Below are two images that should be used to assist in development of your program. Items are selected on the Order Calculator and the Message window that displays the Subtotal, Tax and Total is displayed when the Calculate...