TITLE
AnnualSalary and BMIAdult_Calculator
TIME TO COMPLETE
Two weeks
COURSE OBJECTIVES – LEARNING OUTCOME
After finishing the lab2 students should know:
[LO1]
-Declare variables, initialize values of primitive data types
-Apply math operators on numeric variables
-Write a java program with basic with comments and documentation
[LO5]
Analyze problems and design algorithms using pseudo-code, flowcharts, and structured charts, UML
[LO11]
-Can read input from the keyboard and from input files
-Can write output to the screen and to the output files
-display messages by using dialog box
LAB OBJECTIVES
· Complete the lab on time (Time Management)
· Write the pseudo-code
· Create a new project, add source file to the project, compile and run the program without errors and qualified to the requirement
· Complete the lab on time (Time Management)Display strings and numbers on the screen
· Declare variables, assign values to int or string variables
· Write the comment
· Apply math operations to calculate the saving money
· display output in columns
SKILLS REQUIRED
To do this lab, students have to know the following:
(You can read topics from TIPS FOR LABS on eCampus to learn how to do)
Review concepts from the previous labs and the following:
ADDITIONAL CONCEPTS:
1.
Use Math calculation on int, float variables: sum, minus, multiple, divide
2.
Read a string from the keyboard that contains spaces; not just a word; using nextLine() instead of next()
for example,
Scanner keyboard = new Scanner(System.in);
String str;
str = keyboard.nextLine() // users type: This is a test
System.out.println( str );
// the output should be whole string “This is a test”
3.
-Display output on the screen with the information laid out in columns and aligned to left or right. Using
String.format() to format an output string
For example:
System.out.println(String.format(“-30s10.1f”, “This test is on the left”, 125.42));
System.out.println(String.format(“-30s10.1f”, “This test is on the left”, 4.23456));
The output will be:
This test is on the left: 125.4
This test is on the left: 4.2
HOW TO DO EACH PART
From now and on yourLastName will be changed to your last name
*Step1: Read the requirement of each part; write the pseudo-code in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab2_pseudoCode_yourLastName
*Step2:
-start editor (for example eClipse) create the project with the following project name:
SU2020_LAB2PART1_yourLastName (part 1)
SU2020_LAB2PART2_yourLastName (part 2)
-add a driver class (file with extension .java) that contain main()
Class: AnnualSalary_yourLastName
(part1)
Class: BMIAdult_Calculator_yourLastName
(part2)
*Step3: read instruction in part 1 (or part 2), write the pseudo-code (or draw the flowchart) then follow step by step in the pseudo-code (or the flowchart) to write the java code
*Step:4
compile and run the program
*Step5: debug if there are any errors to complete the program
REQUIREMENT
LAB2 PART1
IF YOU DO NOT HAVE THE PSEUDO-CODE, YOU HAVE TO READ THE BELOW REQUIREMENT THEN WRITE THE PSEUDO-CODE BEFORE WRITING THE CODE
Add the code to the driver class to create the application that helps Employees to calculate their annual salary that they get after a year.
The application should display message to ask users to enter their information from the keyboard about:
* employee name (string)
* hourly salary (float)
* number of working hours in each week (int)
One year has 52 weeks, then the formula to calculate the annual salary:
Annual salary = hourly salary * number of working hours per week * 52
Display the result in the following format. The information is displayed in two columns. The information of the second column should be aligned to the right and the decimal numbers should be displayed with 1 decimal digits
For example: if the name of the investor is `Mary Lane, hourly salary is 21.5 and number of working hours in one week is 40 then the output is as below:
------------------------------------------------------
File: AnnualSalary_White.java
Salary Application – McKINLEY WHITE
------------------------------------------------------
Name of investor: Mary Lane
Hourly salary: 21.5
Number of working hours in each week: 40
------------------------------------------------------
Yearly salary is: 44720.0
REQUIREMENT:
*Your program should change White to your last name
*Your program should change McKINLEY WHITE to your name
*Change Mary Lane to the name of user who is using the Investment Application entered from the keyboard
*Write the file name as the first comment line at the top of program
*After running your program, get the picture of the output window from your program with your name on to paste at the bottom of the pseudo-code to turn in
LAB2 PART2
IF YOU DO NOT HAVE THE PSEUDO-CODE, YOU HAVE TO READ THE BELOW REQUIREMENT THEN WRITE THE PSEUDO-CODE BEFORE WRITING THE CODE
Provide the application to calculate the BMI of Adults.
The application should display message to ask users to enter the users’ information from the keyboard about:
*The name of user (string)
*Height in feet (int)
*Weight in pounds (int)
The formula to calculate BMI:
BMI = (weight * 703) / (height * height)
For example: Your name is Luis Martinez, the name of user is Mary Lane, the height is 6 feet 8 inches, the weight is 188 pounds then the output as below:
-------------------------------------------
File: BMIAdult_Calculator_White.java
Summer Semester – McKINLEY WHITE
Standard BMI: 18.5 – 24.9
-------------------------------------------
Name: Mary Lane
Height: 80
Weight: 188
------------------------------------------
BMI: 20.65
REQUIREMENT:
*Your program should change McKINLEY WHITE to your name
*Change White to your last name
*Change Mary Lane to the name of user who is using the BMI Application entered from the keyboard
*Write the file name as the first comment line at the top of program
*After running your program, get the picture of the output window from your program with your name on to paste at the bottom of the pseudo-code to turn in
HOW TO TURN IN THE LAB
You should turn in the following files:
Pseudo-code and the
output pictures
of both parts
(yourLastName should be your last name)
AnnualSalary_yourLastName.java
BMIAdult_Calculator_yourLastName.class
AnnualSalary_yourLastName.java
BMIAdult_Calculator_yourLastName.class
IF YOU GET ANY PROBLEM TO SUBMIT FILEs .class YOU CAN COMPRESS ALL PROJECT INTO ONE FILE .zip or .rar TO UPLOAD TO eCampus