Create a book Order Class.Every book order object includes a name of the book, n
ID: 3814741 • Letter: C
Question
Create a book Order Class.Every book order object includes a name of the book, number of books in the order, and individual price of the book. You should have methods that compute the tax paid on the order(7.5%of the total cost), compute the shipping cost of the order($2 per book),compute total cost of the order including tax and shipping cost, and print out all necessary information about he order as a whole. You should also have a tester program that allows the user to make three different orders prompting them to input all necessary order information. The tester program should let the user know the final cost of their individual orders as well as the total cost of all three combined. Print all necessary information in the proper format.
Explanation / Answer
Below is the solution for your question. As you didn't mentioned any of the preferred languages from your side
so i decided to write it using my experitse area. Hence, i wrote the program in JAVA.
Hope this helps!!!!
import java.util.*;
class orderBooks
{
public static void main(String [] args)
{
final double COFFEE_BOOK_PRICE = 5.50;
final double LARGE_BOOK_PRICE = 1.80;
final double MEDIUM_BOOK_PRICE = 1.00;
final double SMALL_BOOK_PRICE = 0.60;
final double TN_TAX = 0.0925;
double bulkDiscount = 0;
double coffeeBooksOrdered;
double bookCost;
double subTotal;
double discountAmount;
double boxCost;
double taxAmount;
double totalCost;
int largeBox;
int mediumBox;
int smallBox;
Scanner input = new Scanner(System.in);
System.out.println("Number of Bags Ordered: ");
while((coffeeBooksOrdered = input.nextDouble())%1 != 0)
{
System.out.println("Please enter a whole number.");
}
System.out.println(coffeeBooksOrdered + " - $" + coffeeBooksOrdered*COFFEE_BAG_PRICE);
if(coffeeBooksOrdered >= 25) { bulkDiscount = .05; }
if(coffeeBooksOrdered >= 50) { bulkDiscount = .10; }
if(coffeeBooksOrdered >= 100) { bulkDiscount = .15; }
if(coffeeBooksOrdered >= 150) { bulkDiscount = .20; }
if(coffeeBooksOrdered >= 200) { bulkDiscount = .25; }
if(coffeeBooksOrdered >= 250) { bulkDiscount = .30; }
System.out.println("Discount: " + bulkDiscount*100 + "% - $" + coffeeBooksOrdered*bulkDiscount);
largeBox = (int) coffeeBooksOrdered/20;
mediumBox = (int) (coffeeBooksOrdered%20)/10;
if(coffeeBooksOrdered%10 <= 5)
{
smallBox = 1;
}
if(coffeeBooksOrdered%10 > 5 )
{
smallBox = 2;
}
else
{
smallBox = 0;
}
boxCost = largeBox*LARGE_BOOK_PRICE + mediumBox*MEDIUM_BOOK_PRICE + smallBox*SMALL_BOOK_PRICE;
bookCost = coffeeBooksOrdered*COFFEE_BOOK_PRICE;
discountAmount = coffeeBooksOrdered*bulkDiscount;
subTotal = bookCost + boxCost;
taxAmount = subTotal*TN_TAX;
totalCost = subTotal + taxAmount;
System.out.println("Boxes Used:");
if(largeBox > 0) { System.out.println(" " + largeBox + " Large - $" + (largeBox*LARGE_BOOK_PRICE)); }
if(mediumBox > 0) { System.out.println(" " + mediumBox + " Medium - $" + (mediumBox*MEDIUM_BOOK_PRICE)); }
if(smallBox > 0) { System.out.println(" " + smallBox +" Small - $" + (smallBox*SMALL_BOOK_PRICE)); }
System.out.println("Your total charge before taxes is: $" + subTotal);
System.out.println("Your tax is: $" + taxAmount);
System.out.println("Total Charge: $" + totalCost);
}
}