Prerequisites: Set up the Java SDK (also called JDK and Eclipse on your developm
ID: 3842624 • Letter: P
Question
Prerequisites: Set up the Java SDK (also called JDK and Eclipse on your development machine if you choose to do so Purchase/Register for the Pearson/REVEL Liang 10 Edition, Java online textbook. Read Chapter 1 Working with Eclipse: Eclipse is an IDE (Integrated Development Environment). Its purpose is to facilitate Java software development (also called coding or programming) utilizing an integrated set of features including an Editor, Compiler, Debugger, etc ltwillhighlight syntax errors so that you can fix them (debugging), and allow you go generate your output. Part I Points: Create an Eclipse Project Java Class a. Open Eclipse from the menu (ower left of screen) then choose Programming Eclipse Source b. Eclipse will ask for a workspace. Choose your U drive folder because, later in the lab you will need to go to this path to find your files, which can be done from any lab computer. c. Create a new project in Eclipse, using File New- d. A Select Wizard pop up will appear, choose the Java Project wizard. e. Give your project the name "HelloWorld' then click f. A Java Settings will appear next, leave the defaults, method stubs would you Mke to creater and just click Finish. To create a Java program: Constructors from superetass In your new Java project right click on the src folder, choose New Class. Dovou want to add commorntwheConngure templates and default value hetsl In the dialog box name the class HelloWorld and make sure to check the "public static void main0 checkbox Cick Finish. g. Use the Editor to create the HelloWorld java program source code file with the following code: (DO NOT copy and paste, because the quote characters do not copy into Eclipse nicely) To Run the program, click Run- Run in the Eclipse menu. Congratulations! You've just seen your first Java compilation error! Now, correct the error by replacing System out.p with System.out println. ll Starting Code: Run the program again, and you'll see Hello World appear at public class Helloworld the bottom of the screen on the console window. public static void main(StringO args) Add appropriate comments including a single line comment with your name Written by Your Name. Also, add a multi- System out pr Hello, World! line comment with identifying information including: Assignment with short description Course Title, Section and Semester Date and Instructor NameExplanation / Answer
OperateOnNumbers.java
//Starting Code
import java.util.Scanner;
public class OperateOnNumbers {
public static void main(String[] args) {
//Create Scanner object to read the values entered in the console
Scanner scan=new Scanner(System.in);
//Display on console to enter the numbers
System.out.println("Enter the numbers: ");
//declare floating point variables n1 and n2 and assign the values entered in the console
float n1=scan.nextFloat();
float n2=scan.nextFloat();
//declaring floating poing variables to store results for four different calculations
float result1=n1+n2;
float result2=n1-n2;
float result3=n1*n2;
float result4=n1/n2;
//Display the results using System.out.println
System.out.println("Addition.........."+result1);
System.out.println("Subtraction......."+result2);
System.out.println("Multiplication...."+result3);
System.out.println("Division.........."+result4);
}
}
Sample Output:
Enter the numbers:
8
9
Addition..........17.0
Subtraction.......-1.0
Multiplication....72.0
Division..........0.8888889
HelloWorld.java
//Starting Code
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello,World!");
}
}
Sample Output:
Hello,World!
Made changes to Salary.java as mentioned in the assignment, considered tax rate as 15%
Salary.java
//Starting Code
public class Salary {
public static void main(String[] args) {
// declare variables
double wage = 12.50;
int hours = 20;
int weeks = 52;
double grossPay = 0.0;
double taxRate= 0.15;
double taxAmount;
double netPay;
// generate messages
System.out.println("Salary Calculator program ");
// Perform calculations
grossPay = wage * hours * weeks;
taxAmount=grossPay*taxRate;
netPay=grossPay-taxAmount;
System.out.println("Your Annual Salary before taxes is: ");
System.out.println(grossPay+"$");
System.out.println(" Your Annual Salary After taxes is: ");
System.out.println(netPay+"$");
System.out.println(" **** End of the Program ****");
}
}
Sample Output:
Salary Calculator program
Your Annual Salary before taxes is:
13000.0$
Your Annual Salary After taxes is:
11050.0$
**** End of the Program ****