Using Java language figure out a solution to the following T

Using Java language, figure out a solution to the following. Thanks

A college bookstore wants to estimate its business for next term. Experience has shown that sales for a course textbook depend greatly on whether a book is required or just suggested reading, and whether or not it has been used for a course in previous terms. The bookstore tells you that a new, required book will sell to 90% of prospective course enrollment, but if it has been used before, only 65% will buy. Similarly, 40% of the prospective enrollment will buy a new, suggested book, but just 20% will buy a book which is suggested and is old.

Write a program that takes as input a book\'s identification number, the book\'s single-copy cost (the price the store pays to buy the book from its supplier), the current number of volumes on hand, the prospective course enrollment (for a particular course), and data that indicates whether the textbook is required or suggested, as well as whether it is new or old. As output, first give the number of books that must be ordered (if any). Then, if books must be ordered, show the total cost the store must pay for the books ordered, and the expected profit on the books ordered assuming that the store pays 80% of list price to obtain them from its supplier, and sells them for list price.

This program requires that you read in the following data values: z book ID number (an integer) z cost per copy (a real number) z volume on hand (an integer) z expected enrollment (an integer) z code for required versus suggested (a character, \'R\' or \'S\') z code for new versus used (a character, \'N or \'O\')

Thank You

Solution


/**
* The java program bookstore that prompts user to enter
* book id, cost per copy, volum on hand, expected enrollment,
* and required or suggested and new or old and then calculates
* books to order ,total cost and expected profit to console.
* */
//bookstore.java
import java.util.Scanner;
public class bookstore {
  
   public static void main(String[] args) {
      
       //Create a Scanner class object
       Scanner scanner=new Scanner(System.in);
      
       int bookID;
       double costPerCopy;
       int volumeOnHand;
       int expectedEnrollment;
      
       char RorS;
       char NorO;
      
       int toOrder;
       double orderPercentage=0;
       double expectedCost=0;
       double expectedProfit=0;
      
      
       System.out.println(\"**************************************************\");
       System.out.println(\"   WELCOME TO THE BOOKSTORE ORDER ESTIMATION PROGRAM!\");
       System.out.println(\"**************************************************\");
      
      
       System.out.println(\"Enter the book ID number -> \");
       bookID=Integer.parseInt(scanner.nextLine());
       System.out.println(\"Enter the book\'s cost per copy -> \");
       costPerCopy=Double.parseDouble(scanner.nextLine());
      
       System.out.println(\"Enter the current volume on hand -> \");
       volumeOnHand=Integer.parseInt(scanner.nextLine());
      
      
       System.out.println(\"Enter the expected class enrollment -> \");
       expectedEnrollment=Integer.parseInt(scanner.nextLine());
      
       System.out.println(\"Is the book required or suggested? Enter \'R\' or \'S\' -> R \");
       RorS=scanner.nextLine().charAt(0);
      
       System.out.println(\"Is the book new (has been used before) or old (has not)?   \");
       NorO=scanner.nextLine().charAt(0);
      
      
       if(RorS==\'R\' && NorO==\'N\')
           orderPercentage=0.9;
       else if(RorS==\'R\' && NorO==\'O\')
           orderPercentage=0.65;      
       else if(RorS==\'S\' && NorO==\'N\')
           orderPercentage=0.4;
       else if(RorS==\'S\' && NorO==\'O\')
           orderPercentage=0.2;
      
       //calculate total order
       int totalOrder=(int) Math.ceil(expectedEnrollment*orderPercentage);
      
       //calculate toorder books
       toOrder=totalOrder-volumeOnHand;
      
      
       //calculate expected cost
       expectedCost=toOrder*costPerCopy;
      
      
       double totalCost=(expectedEnrollment-volumeOnHand)*costPerCopy;
      
       //calculate expected profit
       expectedProfit=totalCost-expectedCost;
      
       System.out.println(\"   BOOK ORDER ESTIMATION SUMMARY \");
       System.out.println(\"   ----------------------------- \");
       System.out.println(\"   Number of Books to Order:\"+toOrder);
       System.out.println(\"   Total Cost of this Order: $ \"+expectedCost);
       System.out.printf(\"   Expected Profit on Books Ordered: $ %5.2f\",expectedProfit);
      
      
      
   }
}

Sample output:

**************************************************
   WELCOME TO THE BOOKSTORE ORDER ESTIMATION PROGRAM!
**************************************************
Enter the book ID number ->
101
Enter the book\'s cost per copy ->
12.95
Enter the current volume on hand ->
12
Enter the expected class enrollment ->
21
Is the book required or suggested? Enter \'R\' or \'S\' -> R
R
Is the book new (has been used before) or old (has not)?
N
   BOOK ORDER ESTIMATION SUMMARY
   -----------------------------
   Number of Books to Order:7
   Total Cost of this Order: $ 90.64999999999999
   Expected Profit on Books Ordered: $ 25.90

Using Java language, figure out a solution to the following. Thanks A college bookstore wants to estimate its business for next term. Experience has shown that
Using Java language, figure out a solution to the following. Thanks A college bookstore wants to estimate its business for next term. Experience has shown that
Using Java language, figure out a solution to the following. Thanks A college bookstore wants to estimate its business for next term. Experience has shown that

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site