
Big Java, Binder Ready Version: Early Objects
6th Edition
ISBN: 9781119056447
Author: Cay S. Horstmann
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 3PE
Program Plan Intro
Invoice
Program plan:
Filename: “Address.java”
This program file is used to define a class “Address”. In the code,
- Define a class “Address”.
- Define the class members.
- Define a constructor “Address()”.
- Set the values for class members.
- Define a method “getName()”.
- Return the “name”.
- Define a method “getStreet()”.
- Return the “street”.
- Define a method “getCity()”.
- Return the “city”.
- Define a method “getState()”.
- Return the “state”.
- Define a method “getZip()”.
- Return the “zip”.
Filename: “Invoice.java”
This program file is used to define a class “Invoice”. In the code,
- Import the required packages.
- Define a class “Invoice”.
- Define the class members.
- Define a constructor “Invoice()”.
- Set the class elements.
- Define the method “add()”.
- Create an object “anItem” of class “LineItem”.
- Call the method “add()” recursively.
- Define a method “getAmountDue()”.
- Define the variable “amountDue”.
- Iterate a “for” loop,
- Calculate the value of “amountDue”.
- Return the value of “amountDue”.
- Calculate the value of “amountDue”.
- Define a method “getLineItem()”.
- Return the item.
- Define a method “getLineItemCount()”.
- Return the size of the item.
- Define a method “getAddress()”.
- Return the “billingAddress”.
Filename: “InvoiceFormatter.java”
This program file is used to define a class “InvoiceFormatter”. In the code,
- Import the required packages.
- Define a class “InvoiceFormatter”.
- Define the class members.
- Define a constructor “InvoiceFormatter ()”.
- Set the class elements.
- Define a class “format()”.
- Define the constants “DESCRIPTION_WIDTH”, “PRICE_WIDTH”, “QTY_WIDTH”, “TOTAL_WIDTH”.
- Define a string variable “r” and get the invoice to it.
- Iterate a “for” loop,
- Get the items to “item”.
- Format the invoice and assign it to “r”.
- Call the method “format” to format the amount due and add the result to “r”.
- Return “r”.
Filename: “LineItem.java”
This program file is used to define a class “LineItem”. In the code,
- Import the required packages.
- Define a class “LineItem”.
- Define the class members.
- Define a constructor “LineItem()”.
- Set the class elements.
- Define a method “getTotalPrice()”.
- Multiply the price and quantity and return the result.
- Define a method “getDescription()”.
- Return the description.
- Define a method “getPrice()”.
- Return the price.
- Define a method “getQuantity()”.
- Return the quantity.
Filename: “Product.java”
This program file is used to define a class “Product”. In the code,
- Import the required packages.
- Define a class “Product”.
- Define the class members.
- Define a constructor “Product()”.
- Set the class elements.
- Define a method “getDescription()”.
- Return the “description”.
- Define a method “getPrice()”.
- Return the “price”.
Filename: “InvoicePrinter.java”
This program file is used to define a class “InvoicePrinter”. In the code,
- Define a class “InvoicePrinter”.
- Define a method “main()”.
- Define the object “samsAddress” of class “Address”.
- Define the object “samsInvoice” of class “Invoice”.
- Call the method “add()” using “samsInvoice” to add the products.
- Define the object of “InvoiceFormatter”.
- Print the formatted invoice.
- Define a method “main()”.
Expert Solution & Answer

Want to see the full answer?
Check out a sample textbook solution
Students have asked these similar questions
I need help to solve the following case, thank you
hi I would like to get help to resolve the following case
Could you help me to know features of the following concepts:
- defragmenting.
- dynamic disk.
- hardware RAID
Chapter 12 Solutions
Big Java, Binder Ready Version: Early Objects
Ch. 12.1 -
What is the rule of thumb for finding classes?
Ch. 12.1 -
Your job is to write a program that plays chess....Ch. 12.1 - Suppose the invoice is to be saved to a file. Name...Ch. 12.1 - Looking at the invoice in Figure 1, what is a...Ch. 12.1 - Prob. 5SCCh. 12.2 - Consider the CashRegisterTester class of Section...Ch. 12.2 - Prob. 7SCCh. 12.2 - Consider the Quiz class described in Section...Ch. 12.2 - Why should coupling be minimized between...Ch. 12.2 - Prob. 10SC
Ch. 12.2 - You are implementing a system to manage a library,...Ch. 12.2 - Prob. 12SCCh. 12.3 - Which class is responsible for computing the...Ch. 12.3 - Prob. 14SCCh. 12 - Prob. 1RECh. 12 - Give a rule of thumb for how to find classes when...Ch. 12 - Give a rule of thumb for how to find methods when...Ch. 12 - Prob. 4RECh. 12 - Prob. 5RECh. 12 - Prob. 6RECh. 12 - Prob. 7RECh. 12 - Prob. 8RECh. 12 - Prob. 9RECh. 12 - Prob. 10RECh. 12 - Prob. 11RECh. 12 - Prob. 12RECh. 12 - Prob. 13RECh. 12 - Prob. 14RECh. 12 - Prob. 15RECh. 12 - Prob. 1PECh. 12 - Prob. 2PECh. 12 - Prob. 3PECh. 12 - Prob. 4PECh. 12 - Prob. 5PECh. 12 - Prob. 6PECh. 12 - Prob. 1PPCh. 12 - Prob. 2PPCh. 12 - Prob. 3PPCh. 12 - Prob. 4PPCh. 12 - Prob. 5PPCh. 12 - Prob. 6PPCh. 12 - Prob. 7PPCh. 12 - Prob. 8PPCh. 12 - Prob. 9PPCh. 12 - Prob. 10PP
Knowledge Booster
Similar questions
- what is a feature in the Windows Server Security Compliance Toolkit, thank you.arrow_forwardYou will write a program that allows the user to keep track of college locations and details about each location. To begin you will create a College python class that keeps track of the csollege's unique id number, name, address, phone number, maximum students, and average tuition cost. Once you have built the College class, you will write a program that stores College objects in a dictionary while using the College's unique id number as the key. The program should display a menu in this order that lets the user: 1) Add a new College 2) Look up a College 4) Delete an existing College 5) Change an existing College's name, address, phone number, maximum guests, and average tuition cost. 6) Exit the programarrow_forwardShow all the workarrow_forward
- Show all the workarrow_forward[5 marks] Give a recursive definition for the language anb2n where n = 1, 2, 3, ... over the alphabet Ó={a, b}. 2) [12 marks] Consider the following languages over the alphabet ={a ,b}, (i) The language of all words that begin and end an a (ii) The language where every a in a word is immediately followed by at least one b. (a) Express each as a Regular Expression (b) Draw an FA for each language (c) For Language (i), draw a TG using at most 3 states (d) For Language (ii), construct a CFG.arrow_forwardQuestion 1 Generate a random sample of standard lognormal data (rlnorm()) for sample size n = 100. Construct histogram estimates of density for this sample using Sturges’ Rule, Scott’s Normal Reference Rule, and the FD Rule. Question 2 Construct a frequency polygon density estimate for the sample in Question 1, using bin width determined by Sturges’ Rule.arrow_forward
- Generate a random sample of standard lognormal data (rlnorm()) for sample size n = 100. Construct histogram estimates of density for this sample using Sturges’ Rule, Scott’s Normal Reference Rule, and the FD Rule.arrow_forwardCan I get help with this case please, thank youarrow_forwardI need help to solve the following, thank youarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education