首页 > > 详细

讲解 Java Lab 4 Fall 2021辅导 留学生Java程序

Java Lab 4

Fall 2021

Due: Saturday September 11, 10:10 AM EDT

In this lab, you will practice with simple input and output.

1. Create a project named Lab4. Download the file IfSwitch.java from Canvas and copy it to the src directory. Take a look at the code.

2.  Run the program; enter the requested data. You'll be entering your height in feet and inches (you can make up the data).

3. Compute the height in all inches – there are 12 inches in a foot.  Display that.

4. Prompt the user to enter their gender; for simplicity – but clearly not for correctness, sorry – tell the user to enter M for male and F for female. If the user fails to enter M or F, set the gender to F. Display it.

5. Write if statements for the following: if the person's height is less than 64 inches and they registered as female, print: you're shorter than average, but if they're 64 or more and female, print: you're taller than average.

Do the same for males, where the average height is 69 inches. (CDC averages for Americans)

6. Now add code between #4 and #5 that does a quick error check: if less than 21 inches or greater than 107 inches (shortest and tallest ever, according to Guinness World Records), display an error message. Then set the height to the average for the user's gender.

7. Add a new section that does the same thing as #5, but uses a switch statement to classify according to gender (with a default case with an error message), and uses if statements inside the two gender cases to do the comparisons to the averages.

8. Prompt the user to enter an integer test score. Then compute the letter grade based on the scale 90-100 is an A, and so on down to 0-59 is an F. If the score is out of range, print an error message. Next, use a switch statement based on the letter grade to display the GPA value of the letter grade: an A is 4.0, B is 3.0, and so on.

Deliverable: Add your name and Andrew id to the comment at the top of the file. Upload the file to Canvas.


联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!