Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1: Practicing Problem Analysis, Design, and Coding Step 1. Problem Statement A company named Acme Software Company needs to develop a Java application that
Part 1: Practicing Problem Analysis, Design, and Coding Step 1. Problem Statement A company named Acme Software Company needs to develop a Java application that can maintain software purchasing information and print an invoice for a customer. There are two available softwares that a customer can purchase from Acme Software: 1. Code: SF001, Name: Chess for Beginners, Price: $99.0 2. Code: SF002, Name: Chess for Novices, Price: $150.0 Here are some additional specifications: . Instance Variables: The Invoice class should have instance variables to represent the customer's name and the code of the software that is being purchased. Constructor Method: A constructor method should allow the customer's name and software code to be set when an instance of this class is created. Instance Methods: The Invoice class should include mutator and accessor --set() and get()--methods for each of its instance variables. Output Method: The Invoice class should contain a printInvoice() method that prints a Output Method: The Invoice class should contain a printInvoice() method that prints a hard copy of the invoice. You need to calculate the total purchase price depending on the software the customer purchase. Here's a sample of a printed invoice: Acme Software Invoice Customer Name: Alex Software Code: SF001 Software Name: Chess for Beginners Amount Due: $99.00 Step 2: Problem Decomposition This problem can be divided into two classes 1. Invoice class: represents the Invoice object. This class should have the following instance variables: o customer_name: stores the customer name o software_code: stores the purchase software code o software_name: stores the name of the purchased software software_price: stores the price of such the software This class should have the following public methods: Invoice(String c_name, String s_code): the constructor method that will receive the input customer name (c_name) and the purchased software code (s_code) o This class should have the following public methods: o Invoice(String c_name, String s_code): the constructor method that will receive the input customer name (c_name) and the purchased software code (s_code) o setSoftwareName(String s_name): set the name of the software with the input (s_name) o getSoftwareName(): get the name of software o setSoftware Price(double price): set the price of the software with input (price) getSoftware Price(): get the name of software printlnvoice(): print the hard copy of invoice to console Check the specifications in Step 1 for the format of printed invoice. Note: you have to calculate the right amount due based on the software code (e.g., SF001 and SF002). O o 2. InvoiceApp class: reads the user's input of name and the purchased software code and contains a main() method in which Invoice instances will be created and used. This class should have the following public methods: o readUserName(): Read the input of customer name from console and return a String o readSoftwareCode(): Read the input of software code from console and return a String o main(): Create an instance of InvoiceApp to read user input of customer name and software code. Then create an instance of Invoice, set the software name and price based on the input software code, and finally print the invoice to console. Sten 2. Problem Design based on the input software code, and finally print the invoice to console. Step 3: Problem Design Draw a UML class diagram to describe the design of the Invoice and InvoiceApp class. Your design should identify the of the class, its attributes (instance variables) and behaviors (methods). Designate which elements will be hidden and which parts of the class will make up its public interface. Step 4: Problem Implementation 4.1 Implement the Invoice class Similar to Lab3, We will use the stepwise refinement approach that we practiced last time to code and test the Invoice class. Here's a sequence of appropriate steps, after each of which you should compile and run your program. 1. Create a Eclipse project named Lab5, and saving the project on your workspace. Then, create the Invoice class. 2. Type the Invoice class design specification you developed in Step 3 into a Java comment block at the beginning of the Invoice.java file. This file will be the file you use for defining the Invoice class. Here's an example format that you can use: /** * the class design specification 1. Create a Eclipse project named Lab5, and saving the project on your workspace. Then, create the Invoice class. 2. Type the Invoice class design specification you developed in Step 3 into a Java comment block at the beginning of the Invoice.java file. This file will be the file you use for defining the Invoice class. Here's an example format that you can use: /** * the class design specification 7 Similar to Lab3, you should include the following information in the comment block: o Class Name: Invoice o Author: o Date: Role: The role/purpose of this class o Attributes: List all attributes (role, data type, and scope (public/private)) o Public methods: List all public methods 3. Code the declarations for the class's instance variables (customer_name, software_code, software_name, software_price) using the following stater code. private String customer_name; //TODO: add the code for the remaining variables 4. Code the declarations for the constructor method using the following starter code. public Invoice(String c_name, String s_code) { //TODO: add code of this constructor method below } 5. Code the definition for the remaining methods, one at a time. public void setSoftwareName(String s_name) { //TODO: add code of the setSoftwareName method below } public String getSoftwareName() { //TODO: add code of the getSoftwareName method below } public void setSoftwarePrice(double s_price) { //TODO: add code of the setSoftwarePrice method below } public double get varePri //TODO: add code of the getSoftwarePrice method below } public void printInvoice() { //TODO: add code of the printInvoice method below } 4.2 Implement the InvoiceApp class Here's a sequence of appropriate steps, after each of which you should compile and run your program. Here's a sequence of appropriate steps, after each of which you should compile and run your program. 1. Create the InvoiceApp class. 2. Type the InvoiceApp class design specification you developed in Step 3 into a Java comment block at the beginning of the InvoiceApp.java file. Here's an example format that you can use: Similar to Lab3, you should include the following information in the comment block: o Class Name: InvoiceApp o Author: o Date: Role: The role/purpose of this class o Problem Description: that defines your application - include name of the project and reason for the development work. Elaborate as you see fit - keeping the scope manageable (2 - 3 sentences) o Goals of your application: State in a way so the end user knows what your software can do (can be used as). o Enumerate all the inputs and outputs for your application (provide examples) List all the java packages that need to be imported - tools that will be needed for solving/coding the problem. Describe specifically your input and output screen formats - a brief sketch is an excellent starting point. 3. Code the readUserName () method to read the user's input of the customer name with the following starter code 3. Code the readUserName() method to read the user's input of the customer name with the following starter code public String readUserName() { //TODO: add code of the readUserName method below } 4. Code the readSoftwareCode () method to read the user's input of the purchased software code with the following starter code public String readSoftwareCode() { // TODO: add code of the readSoftwareCode method below } 5. Add code to the main method to create and use one InvoiceApp object to read user input, and one Invoice object set the corresponding software name and price. Then print the invoice to console. Below is the starter code for this main method: public static void main(String[] args) { //TODO: add code of this main method below } The main() method code should be implemented by referencing the following flowchart design (Hint: use String class's equals() method to determine if a String variable is equal to "SF001" or "SF002"): Create an instance of InvoiceApp Invoice to console. Below is the starter code for this main metnloa! public static void main(String[] args) { 7/TODO: add code of this main method below } The main() method code should be implemented by referencing the following flowchart design (Hint: use String class's equals() method to determine if a String variable is equal to "SF001" or "SF002"): Create an instance of Invoice App Read customer name by calling readCustomerName() Read software code by calling readSoftwareCode() Create new instance of Invoice with previous inputs Set Software Name and Price Print the Invoice Yes code = "SF001"? No Set Software Name and Price Print the Invoice Yes code = "SF002"? No - Set Software Name and Price - Print the Invoice Yes code = "SF002"? No Print error that the code is not valid or not found 6. Complete the documentation for your program. Add useful comments to your code that will make your program more readable. A good rule might be that you should be able to read your program two years from now and still understand what it does. You are recommended to add code comments before the method definition such as method descriptions, inputs/outputs of methods, pseudocode if any. Also, try to add comment inside the method body. Step 5: Testing In this part, we will test our developed program in the previous steps. You are required to run the compiled of your program with different set of inputs (customer name and software code) and capture the screenshots of the outputs of your program of three different cases: (1). software code: SF001 (2). software code: SF002 In this part, we will test our developed program in the previous steps. You are required to run the compiled of your program with different set of inputs (customer name and software code) and capture the screenshots of the outputs of your program of three different cases: (1). software code: SF001 (2). software code: SF002 (3). software code: test (Note: this should output that: The input software code could not be found! ). Here is a sample output of 3 cases: Problems @ Javadoc Declaration Search Console X InvoiceApp (Java Application) /Library/Java/JavaVirtualMachir Enter the customer name: Alex Enter the software code: SF001 Acme Software Invoice Customer Name: Alex Software Code: SF001 Software Name: Chess for Beginners Amount Due: $99.0 Problems @ Javadoc Declaration Search E Console X InvoiceApp (Java Application] /Library/Java/JavaVirtualMachi Enter the customer name: Alex Enter the software code: SF002 Acme Software Invoice Customer Name: Alex Software Code: SF002 Software Name: Chess for Novices Amount Due: $150.0 Problems @ Javadoc . Declaration Search Console X Problems Javadoc Declaration Search Console a InvoiceApp (Java Application) /Library/Java/JavavirtualMachi Enter the customer name: Alex Enter the software code: SF002 Acme Software Invoice Customer Name: Alex Software Code: SF002 Software Name: Chess for Novices Amount Due: $150.0 Problems @ Javadoc Declaration Search B Console X InvoiceApp (Java Application] /Library/Java/JavaVirtual Machi Enter the customer name: Alex Enter the software code: test The software code is not exist! Submission You need to submit the following results: 1. Capture the outputs in your Eclipse console using screenshot for your program in part 1 (step 5). Write them into a PDF file named result.pdf. Note: the output should be as the same as the sample output. 2. Source code: Submit the exported project Lab5 folder (DO NOT compress it into .zip) to your /your_name/lab5 folder in your class storage. Requirements Write your own code. Part 1: Practicing Problem Analysis, Design, and Coding Step 1. Problem Statement A company named Acme Software Company needs to develop a Java application that can maintain software purchasing information and print an invoice for a customer. There are two available softwares that a customer can purchase from Acme Software: 1. Code: SF001, Name: Chess for Beginners, Price: $99.0 2. Code: SF002, Name: Chess for Novices, Price: $150.0 Here are some additional specifications: . Instance Variables: The Invoice class should have instance variables to represent the customer's name and the code of the software that is being purchased. Constructor Method: A constructor method should allow the customer's name and software code to be set when an instance of this class is created. Instance Methods: The Invoice class should include mutator and accessor --set() and get()--methods for each of its instance variables. Output Method: The Invoice class should contain a printInvoice() method that prints a Output Method: The Invoice class should contain a printInvoice() method that prints a hard copy of the invoice. You need to calculate the total purchase price depending on the software the customer purchase. Here's a sample of a printed invoice: Acme Software Invoice Customer Name: Alex Software Code: SF001 Software Name: Chess for Beginners Amount Due: $99.00 Step 2: Problem Decomposition This problem can be divided into two classes 1. Invoice class: represents the Invoice object. This class should have the following instance variables: o customer_name: stores the customer name o software_code: stores the purchase software code o software_name: stores the name of the purchased software software_price: stores the price of such the software This class should have the following public methods: Invoice(String c_name, String s_code): the constructor method that will receive the input customer name (c_name) and the purchased software code (s_code) o This class should have the following public methods: o Invoice(String c_name, String s_code): the constructor method that will receive the input customer name (c_name) and the purchased software code (s_code) o setSoftwareName(String s_name): set the name of the software with the input (s_name) o getSoftwareName(): get the name of software o setSoftware Price(double price): set the price of the software with input (price) getSoftware Price(): get the name of software printlnvoice(): print the hard copy of invoice to console Check the specifications in Step 1 for the format of printed invoice. Note: you have to calculate the right amount due based on the software code (e.g., SF001 and SF002). O o 2. InvoiceApp class: reads the user's input of name and the purchased software code and contains a main() method in which Invoice instances will be created and used. This class should have the following public methods: o readUserName(): Read the input of customer name from console and return a String o readSoftwareCode(): Read the input of software code from console and return a String o main(): Create an instance of InvoiceApp to read user input of customer name and software code. Then create an instance of Invoice, set the software name and price based on the input software code, and finally print the invoice to console. Sten 2. Problem Design based on the input software code, and finally print the invoice to console. Step 3: Problem Design Draw a UML class diagram to describe the design of the Invoice and InvoiceApp class. Your design should identify the of the class, its attributes (instance variables) and behaviors (methods). Designate which elements will be hidden and which parts of the class will make up its public interface. Step 4: Problem Implementation 4.1 Implement the Invoice class Similar to Lab3, We will use the stepwise refinement approach that we practiced last time to code and test the Invoice class. Here's a sequence of appropriate steps, after each of which you should compile and run your program. 1. Create a Eclipse project named Lab5, and saving the project on your workspace. Then, create the Invoice class. 2. Type the Invoice class design specification you developed in Step 3 into a Java comment block at the beginning of the Invoice.java file. This file will be the file you use for defining the Invoice class. Here's an example format that you can use: /** * the class design specification 1. Create a Eclipse project named Lab5, and saving the project on your workspace. Then, create the Invoice class. 2. Type the Invoice class design specification you developed in Step 3 into a Java comment block at the beginning of the Invoice.java file. This file will be the file you use for defining the Invoice class. Here's an example format that you can use: /** * the class design specification 7 Similar to Lab3, you should include the following information in the comment block: o Class Name: Invoice o Author: o Date: Role: The role/purpose of this class o Attributes: List all attributes (role, data type, and scope (public/private)) o Public methods: List all public methods 3. Code the declarations for the class's instance variables (customer_name, software_code, software_name, software_price) using the following stater code. private String customer_name; //TODO: add the code for the remaining variables 4. Code the declarations for the constructor method using the following starter code. public Invoice(String c_name, String s_code) { //TODO: add code of this constructor method below } 5. Code the definition for the remaining methods, one at a time. public void setSoftwareName(String s_name) { //TODO: add code of the setSoftwareName method below } public String getSoftwareName() { //TODO: add code of the getSoftwareName method below } public void setSoftwarePrice(double s_price) { //TODO: add code of the setSoftwarePrice method below } public double get varePri //TODO: add code of the getSoftwarePrice method below } public void printInvoice() { //TODO: add code of the printInvoice method below } 4.2 Implement the InvoiceApp class Here's a sequence of appropriate steps, after each of which you should compile and run your program. Here's a sequence of appropriate steps, after each of which you should compile and run your program. 1. Create the InvoiceApp class. 2. Type the InvoiceApp class design specification you developed in Step 3 into a Java comment block at the beginning of the InvoiceApp.java file. Here's an example format that you can use: Similar to Lab3, you should include the following information in the comment block: o Class Name: InvoiceApp o Author: o Date: Role: The role/purpose of this class o Problem Description: that defines your application - include name of the project and reason for the development work. Elaborate as you see fit - keeping the scope manageable (2 - 3 sentences) o Goals of your application: State in a way so the end user knows what your software can do (can be used as). o Enumerate all the inputs and outputs for your application (provide examples) List all the java packages that need to be imported - tools that will be needed for solving/coding the problem. Describe specifically your input and output screen formats - a brief sketch is an excellent starting point. 3. Code the readUserName () method to read the user's input of the customer name with the following starter code 3. Code the readUserName() method to read the user's input of the customer name with the following starter code public String readUserName() { //TODO: add code of the readUserName method below } 4. Code the readSoftwareCode () method to read the user's input of the purchased software code with the following starter code public String readSoftwareCode() { // TODO: add code of the readSoftwareCode method below } 5. Add code to the main method to create and use one InvoiceApp object to read user input, and one Invoice object set the corresponding software name and price. Then print the invoice to console. Below is the starter code for this main method: public static void main(String[] args) { //TODO: add code of this main method below } The main() method code should be implemented by referencing the following flowchart design (Hint: use String class's equals() method to determine if a String variable is equal to "SF001" or "SF002"): Create an instance of InvoiceApp Invoice to console. Below is the starter code for this main metnloa! public static void main(String[] args) { 7/TODO: add code of this main method below } The main() method code should be implemented by referencing the following flowchart design (Hint: use String class's equals() method to determine if a String variable is equal to "SF001" or "SF002"): Create an instance of Invoice App Read customer name by calling readCustomerName() Read software code by calling readSoftwareCode() Create new instance of Invoice with previous inputs Set Software Name and Price Print the Invoice Yes code = "SF001"? No Set Software Name and Price Print the Invoice Yes code = "SF002"? No - Set Software Name and Price - Print the Invoice Yes code = "SF002"? No Print error that the code is not valid or not found 6. Complete the documentation for your program. Add useful comments to your code that will make your program more readable. A good rule might be that you should be able to read your program two years from now and still understand what it does. You are recommended to add code comments before the method definition such as method descriptions, inputs/outputs of methods, pseudocode if any. Also, try to add comment inside the method body. Step 5: Testing In this part, we will test our developed program in the previous steps. You are required to run the compiled of your program with different set of inputs (customer name and software code) and capture the screenshots of the outputs of your program of three different cases: (1). software code: SF001 (2). software code: SF002 In this part, we will test our developed program in the previous steps. You are required to run the compiled of your program with different set of inputs (customer name and software code) and capture the screenshots of the outputs of your program of three different cases: (1). software code: SF001 (2). software code: SF002 (3). software code: test (Note: this should output that: The input software code could not be found! ). Here is a sample output of 3 cases: Problems @ Javadoc Declaration Search Console X InvoiceApp (Java Application) /Library/Java/JavaVirtualMachir Enter the customer name: Alex Enter the software code: SF001 Acme Software Invoice Customer Name: Alex Software Code: SF001 Software Name: Chess for Beginners Amount Due: $99.0 Problems @ Javadoc Declaration Search E Console X InvoiceApp (Java Application] /Library/Java/JavaVirtualMachi Enter the customer name: Alex Enter the software code: SF002 Acme Software Invoice Customer Name: Alex Software Code: SF002 Software Name: Chess for Novices Amount Due: $150.0 Problems @ Javadoc . Declaration Search Console X Problems Javadoc Declaration Search Console a InvoiceApp (Java Application) /Library/Java/JavavirtualMachi Enter the customer name: Alex Enter the software code: SF002 Acme Software Invoice Customer Name: Alex Software Code: SF002 Software Name: Chess for Novices Amount Due: $150.0 Problems @ Javadoc Declaration Search B Console X InvoiceApp (Java Application] /Library/Java/JavaVirtual Machi Enter the customer name: Alex Enter the software code: test The software code is not exist! Submission You need to submit the following results: 1. Capture the outputs in your Eclipse console using screenshot for your program in part 1 (step 5). Write them into a PDF file named result.pdf. Note: the output should be as the same as the sample output. 2. Source code: Submit the exported project Lab5 folder (DO NOT compress it into .zip) to your /your_name/lab5 folder in your class storage. Requirements Write your own code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started