
EBK BIG JAVA: EARLY OBJECTS, INTERACTIV
6th Edition
ISBN: 8220102010314
Author: Horstmann
Publisher: YUZU
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
Write the SQL code that permits to implement the tables: Student and Transcript. NB: Add the constraints on the attributes – keys and other.
Draw an ERD that will involve the entity types: Professor, Student, Department and Course. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
Draw an ERD that represents a book in a library system. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
Chapter 12 Solutions
EBK BIG JAVA: EARLY OBJECTS, INTERACTIV
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
- 2:21 m Ο 21% AlmaNet WE ARE HIRING Experienced Freshers Salesforce Platform Developer APPLY NOW SEND YOUR CV: Email: hr.almanet@gmail.com Contact: +91 6264643660 Visit: www.almanet.in Locations: India, USA, UK, Vietnam (Remote & Hybrid Options Available)arrow_forwardProvide a detailed explanation of the architecture on the diagramarrow_forwardhello please explain the architecture in the diagram below. thanks youarrow_forward
- Complete the JavaScript function addPixels () to calculate the sum of pixelAmount and the given element's cssProperty value, and return the new "px" value. Ex: If helloElem's width is 150px, then calling addPixels (hello Elem, "width", 50) should return 150px + 50px = "200px". SHOW EXPECTED HTML JavaScript 1 function addPixels (element, cssProperty, pixelAmount) { 2 3 /* Your solution goes here *1 4 } 5 6 const helloElem = document.querySelector("# helloMessage"); 7 const newVal = addPixels (helloElem, "width", 50); 8 helloElem.style.setProperty("width", newVal); [arrow_forwardSolve in MATLABarrow_forwardHello please look at the attached picture. I need an detailed explanation of the architecturearrow_forward
- Information Security Risk and Vulnerability Assessment 1- Which TCP/IP protocol is used to convert the IP address to the Mac address? Explain 2-What popular switch feature allows you to create communication boundaries between systems connected to the switch3- what types of vulnerability directly related to the programmer of the software?4- Who ensures the entity implements appropriate security controls to protect an asset? Please do not use AI and add refrencearrow_forwardFind the voltage V0 across the 4K resistor using the mesh method or nodal analysis. Note: I have already simulated it and the value it should give is -1.714Varrow_forwardResolver por superposicionarrow_forward
- Describe three (3) Multiplexing techniques common for fiber optic linksarrow_forwardCould you help me to know features of the following concepts: - commercial CA - memory integrity - WMI filterarrow_forwardBriefly describe the issues involved in using ATM technology in Local Area Networksarrow_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