Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

files: Item.java Sale.java This program will read a discount from the user for a sale and inventory from a file, and then create a new

files:

Item.java

Sale.java

This program will read a discount from the user for a sale and inventory from a file, and then create a new file with the discounted sale prices.

Start with an Item class to maintain the data about each item:

Instance variables for code (string), quantity (integer), and price (double)

Get/Set methods for each of the 3 instance variables

Sale class contains main(). Here is pseudocode for main():

//Prompt the user for the discount (an integer)

//Open the input file (originalPrice.txt)

//Open the output file (salePrice.txt)

//For each item in the input file

//Print what you read

//Adjust the price (deduct the discount from each price)

//Write the item to the output file

//Print the updated item (with new price)

Requirements:

Put System.out.println() after each line of input. This will help you match the Test Program and make it easier to use it.

NOTE where to put originalPrice.txt

In NetBeans, put it in the top level folder of your project same level as build.xml and src)

Sample Run #1: (the highlighted text is what the user types)

Discount? 10

Read: 1234 10 3.00

--> 1234 10 2.70

Read: 1235 5 2.50

--> 1235 5 2.25

Read: 1236 1 2.00

--> 1236 1 1.80

Sample Run #1 is based on the following originalPrice.txt (you can find this file in the test zip file)

1234 10 3.00

1235 5 2.50

1236 1 2.00

Sample Run #1 should produce the following salePrice.txt file:

1234 10 2.70

1235 5 2.25

1236 1 1.80

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions