

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


The purpose of this exercise is to apply your knowledge about variables, arithmetic expressions, output statements and the Scanner class discussed during the lectures.
Write a java program that contains a class called Earnings with a main method that performs the following:
The output of your program should look similar this:
Gross Earnings: 4000000. Tax Percent: 35. Tax: 1400000. Net Earnings: 2600000.
You should format the output text in columns using the '\t' escape sequence as discussed during class. Compile and run your program.
Now, edit your program and change the value assigned to the variables grossEarnings and taxPercent to 3500000.00 and 28.5 respectively. Compile and run your program again.
Modify the java program you wrote in exercise to ask the user for the gross earnings of the company. To do this, modify your program as follows:
import java.util.Scanner;
This statement tells the compiler that you will be using objects and methods from the Scanner class.
Compile and run your program. A run of your program should look like this:
Please enter the gross earnings: 560890. Gross Earnings: 560890. Tax Percent: 35. Tax: 196311. Net Earnings: 364578.
After you have completed both exercises in this lab, upload the file Earnings.java in WebCT and submit it to receive credit.