Concatenation of Output to a File

Classic programmed-learning exercises, refreshed for modern Java and presented in the current MrStyner.com portfolio style.

Modern Java noteThis archive has been refreshed for Java 25 LTS. Core language concepts remain useful, while outdated setup instructions and browser-era Java are labeled or replaced. Java 26 is the current feature release; Java 25 is used here as the stable teaching baseline.
go to previous page   go to home page   go to next page        

Answer:

It was replaced with the new discount.out created for this run of the program.

Concatenation of Output to a File

Sometimes you want to run a program several times and put the output of all the runs into a single file. For example, say that you want the discounted price of several items to be saved in one file. Here is how to do this:

C:/>java DiscountErr > discount.out
Enter list price in cents: 100
Enter discount in percent: 10
Discount Price: 90

C:/>java DiscountErr >> discount.out
Enter list price in cents: 150
Enter discount in percent: 15
Discount Price: 128

C:/>java DiscountErr >> discount.out
Enter list price in cents: 200
Enter discount in percent: 30
Discount Price: 140

The double "greater than" signs >> mean to add the new output to the end of the file discount.out. This is called concatenation of the output to a file. Here is what the disk file now looks like:

C:/>type discount.out
Price in cents: 100
Discount: 10
Discount Price: 90
Price in cents: 150
Discount: 15
Discount Price: 128
Price in cents: 200
Discount: 30
Discount Price: 140

C:/>

QUESTION 14:

After all the above has been done, what would be the result of the command:

C:/>java Discount > discount.out