CSE114: Introduction to Object Oriented Programming
Lab 4
Instructions: Complete the steps below. Be sure to upload a copy of all your source code (.java) files to
the link on Brightspace by its deadline, so that you can receive credit for this lab.
1. If you know the balance and the annual percentage interest rate, you can compute the interest
on the next monthly payment using the following formula:
Write a program that reads the balance and the annual percentage interest rate and displays
the interest for the next month.
Here is a sample run:
Enter balance and interest rate (e.g., 3 for 3 %): 1000 3.5
The interest is 2.91667
2. Write a program that prompts the user to enter two points, and and displays
their distance. The formula for computing the distance
Here is a sample run:
Enter x1 and y1: 1.5 -3.4
Enter x2 and y2: 4 5
The distance between the two points is 8.76413445842194
3. The webcomic xkcd gives the following formula to approximate the United States population
for a given year (from 2000 onward):
Obtain the last two digits of the year (for example, 2017 would give you 17)
Subtract 10 from this value
Multiply the result by 3
Add 310
This gives the approximate U.S. population in millions of people.
Write a program (PopulationEstimates.java) that takes an integer representing a four-digit
year as its single argument and prints an integer corresponding to the estimated U.S.
population for that year in millions. CSE114: Introduction to Object Oriented Programming
Here are some sample runs:
Enter a year: 2021
Population estimate (millions of people): 343
Enter a year: 2030
Population estimate (millions of people): 370
Enter a year: 2050
Population estimate (millions of people): 430
Grading Guidelines: This lab is graded on a scale of 0-3 points, assigned as follows:
0 - The student did not attend the lab,
3 - The solutions are complete OR the student spent the entire lab solving the required lab problems
(in this case, the students may not arrive at the lab after the lab started and may not leave until the
lab ends).
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。