Question: Programming Questions 2 . ( 6 points ) The U . S . Census Bureau projects population based on the following assumptions: a . One

Programming Questions
2.(6 points) The U.S. Census Bureau projects population based on the
following assumptions:
a. One birth every 7 seconds
b. One death every 13 seconds
c. One new immigrant every 45 seconds
Write a program to display the population for each of the next five years. Assume that the current population is 312,032,486, and one year has 365 days.
Here is a sample run:
year 1: 314812582
year 2: 317592679
year 3: 320372776
year 4: 323152872
year 5: 325932969
3.(8 points) Write a program that prompts the user to enter the seconds (e.g.,1 billion), and displays the number of years, days, hours, minutes, and seconds. For simplicity, assume a year has 365 days.
Here is a sample run:
Enter number of seconds (e.g.,1 billion)1987000000
In 1987000000 there are: 63 years
In 1987000000 there are: 2 days
In 1987000000 there are: 16 hours
In 1987000000 there are: 26 minutes
In 1987000000 there are: 40 seconds
4.(8 points) Write a program that generates a lottery of a three-digit number. The program prompts the user to enter a three-digit number and determines whether the user wins according to the following rules:
a. If the user input matches the lottery number in the exact order, the award is $10,000.
b. If all digits in the user input match all digits in the lottery number, the award is $3,000.
c. If one digit in the user input matches a digit in the lottery number, the award is $1,000.
Here are sample runs:
Enter your lottery pick (three digits): 591
Lottery is 248
Sorry, no match
Enter your lottery pick (three digits): 987
Lottery is 637
Match one digit: you win $1,000
Enter your lottery pick (three digits): 683
Lottery is 836
Match all digits: you win $3,000
Enter your lottery pick (three digits): 494
Lottery is 494
Exact match: you win $10,000
5.(6 points) Write a program that prompts the user to enter the center coordinates and radii of two circles and determines whether the second circle is inside the first or overlaps with the first, as shown in the below figure.
Hint:
circle2 is inside circle1 if the distance between the two centers <= r1- r2
circle2 overlaps circle1 if the distance between the two centers <= r1+ r2.
Test your program to cover all cases.
Here are sample runs:
Enter circle1s center x-, y-coordinates, and radius: 0.55.113
Enter circle2s center x-, y-coordinates, and radius: 11.74.5
circle2 is inside circle1
Enter circle1s center x-, y-coordinates, and radius: 3.45.75.5
Enter circle2s center x-, y-coordinates, and radius: 6.73.53
circle2 overlaps circle1
Enter circle1s center x-, y-coordinates, and radius: 3.45.51
Enter circle2s center x-, y-coordinates, and radius: 5.57.21
circle2 does not overlap circle1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!