Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Add the import statement import java.util.Scanner; //required for Scanner class. and import javax.swing.JOptionPane; //required for JOptionPane class. with System.exit(0); //required for JOptionPane class. to

1. Add the import statement import java.util.Scanner; //required for Scanner class.

and

import javax.swing.JOptionPane; //required for JOptionPane class.

with

System.exit(0); //required for JOptionPane class.

to your code above the class header except that System.exit(0) must be at the end

of the main method. All the rest of the code shall be in the main method.

  1. Declare the following variables:

    • - numberOfBooks of type int

    • - titleLength of type int

    • - unitPrice of type double

    • - totalCost of type double

    • - authorName, bookTitle, publisher, edition, yearPublisher, firstName, middleName, lastName all of type String except yearPublisher of type int

    • - middleInitial of type char

    • - The customer name: cfirstName, cmiddleName, clastName all of type String.

    • - The customer address: streetAddress, cityName, stateName, zipCode all of type

      String.

  2. Declare and instantiate a Scanner object that can read data from the console (suggested reading pp 84-88 of your text)

  3. Solicit and read an integer value from the console (you choose the input). Store the input in variable numberOfBooks

  4. Solicit and read a number with decimal point from the console (you choose the input). Store the input in variable unitPrice

  5. Assign totalCost the total cost of all books

  6. Solicit the name of your favorite author on the console. Make sure that there is a first

    name, a middle name and a last name in the input. If there is no middle name or you

    do not know it, add a replacement name of your own choice.

  7. Make Scanner read the first name and store it in variable firstName

    Read the middle name and store it in middleName Read the last name and store it in lastName (you will have to call the next( ) method three times)

  8. Extract the middle initial as a character from the middle name and store it in middleInitial

  9. Re-assign all characters of the lastName to be all uppercase version.

  10. Re-build the authors name to be of the format (last name (all in uppercase), first

    name middle initial.). Store it variable authorName.

  11. Solicit the title of your favorite book on the console

  12. Using the nextLine( ) method read the title and store it in variable bookTitle; note

    that you will have to make a dummy call of the nextLine( ) before the actual reading

    works, see pp 88 91 of your book.

  13. Re-assign bookTitle its own all uppercase version

  14. To the console, print the authors name, the bookTitle of the book, followed by publisher, edition and year published. Then the length of the title and how old is the book? (If it is a year or less than a year old book, then you should print It is a year old book. If more than a year such as 73 years, then you need to print It is a 73 years old book.)

  15. Print the result of the order for the book to console as shown in the following template:

     The total cost of 1 book of unit price $245.65 is $ 245.65 from the Jones and Bartlett Publishers. 
  16. Use JOptionPane input dialog box to prompt whether would like to re-order the book.

    If yes, Use JOptionPane input dialog boxes to enter number of the book to be re- ordered and enter the unit price of the book.

  17. Print the result regarding the re-ordered information to console as shown in the following template:

 The total cost for reordered 5 books of unit price $245.65 is $ 1,228.25 from the Jones and Bartlett Publishers. 

19. Your printing must follow exactly the layout as shown below. Use two blocks in which one is for input (You do not have to show the showInputDialog for the input data are used to compute the re-ordered books statement) and then followed by the consecutive printing output statements. (That means, you need to hold off the output until you have all the input data.) Ensure that the singular/plural noun, such as book or books and year or years. You need to use decision structure to get these options.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions