Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program to read quotation detail from a file, allow user to make changes and save the updated quotation to another file. A
Write a program to read quotation detail from a file, allow user to make changes and save the updated quotation to another file. A quotation includes multiple items. Each item consists of a product code, the quantity requested by the customer, the proposed price and discount (if any). The items are stored in a text file as shown below (you may make up your own data): p1,10,50.5,0 p2,50,70.5,0.1 p3,10,0,0 p4,30,10.0,0.05 You may assume the following regarding the values in the file: There can be any number of lines in the file. The product code will be unique. Each line will have exactly 4 values: code, quantity, price and discount. Each value will have the correct data type. However, the values may not be valid. For instance, line 3 contains an invalid price of 0. The program will read each line and store it as an instance of QuotationItem in an ArrayList. The program will ignore (skip) erroneous lines in the file. After that, the program will allow user to perform the following operations repeatedly: 1 Adjust price and discount 2 Show all items 3 Save and quit Option 1 The program will prompt the user to enter product code, price and discount; find the item in the list and update the value(s). If the item does not exist, the program will inform the user accordingly. You will design the operation "flow": what/when to prompt, what/when to check, and how to respond. Option 2 The program will display all items in the list with appropriate information. Option 3 The program will exit the loop, save the updated items into another file, and terminate. Each line of data in the output file will include code, quantity, price, discount and the total amount. The values must be separated by comma. Your program should consist of the following classes. You may add more classes as you deem fit. class QuotationItem code quantity Instance variables price Constructor Get/set methods Instance method Instance method discount You may declare additional variable(s) as you deem fit. The constructor will receive 4 parameters and initialize the instance variables accordingly. Please include necessary get and set methods. getTotal Parameters: None Returns: quantity * price* discount. toString Parameters: None Returns: A descriptive String You may include other methods as you deem fit. class XX_YourName_Lab5 where XX is your tutorial class (e.g. T1, T2, etc.) Read quotation records from file into an ArrayList. Allow user to repeatedly update and show records. Save the updated records to another file upon exit. You may decide on the variables and methods to be included in this class.
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