Assignment: (13 points)For each of these, be certain that there is a comment at the top of the file saying what the program does, who wrote the program, and anyone you received help from. You may not be reminded of this in the future.
0) Divisibility. (0 points)
a) Write a program that asks the user for a number and then reports whether the number is odd or even. (Hint, use modulus)
b) Write a program that asks the user for a number and then reports whether the number is divisible by 3.
NOTHING TO HAND IN FOR THIS ONE!
1) Making change. (3 points)
Write a program that reads in two numbers from the user. The first should represent the amount of a purchase. The second should be the amount that was tendered by the customer. The program should display how much change is due to the customer.
If the customer does not give enough to cover the purchase, the program should inform the user that not enough money was tendered.
Extra credit: Have the program display the number of dollar bills, quarters, dimes, nickels, and pennies which make up the change. (Hint: convert the answer to cents, rather than dollars and cents.)Handin: handin cmsc160 labchange filename.cpp < replacing filename.cpp with whatever you call your file>
2) Phone numbers. (2 points)
Write a program that asks the user for a phone number, in the format 1234567890. The program should then display the formatted equivalent as such: (123) 456-7890
Handin: handin cmsc160 labphone filename.cpp < replacing filename.cpp with whatever you call your file>
3) Country facts (3 points)
Write a program which gives the user the option of seeing information on 5 different countries. When the user picks a country, the program should display 4 pieces of information about that country: the capital city, the currency, and two other pieces of information (your choice).
Handin: handin cmsc160 labcountry filename.cpp < replacing filename.cpp with whatever you call your file>
4) Playing Cards. (2 points)
Problem P3.11 in the book (page 119-120)
Handin: handin cmsc160 labcards filename.cpp < replacing filename.cpp with whatever you call your file>
5) Wind speeds. (3 points)
The Saffir-Simpson scale uses wind speed to classify hurricanes. Write a program that asks the user for the sustained wind speed, and uses the Saffir-Simpson scale and other definitions to classify a storm as follows:
Practice Problems (nothing to hand in)
P0) Car Pricing
Write a program that asks the user for the type of car they own and how much they paid for it. EG:
Type of car: Toyota
Paid: $ 19000
The program should then report if the car was overpriced.
Write a program that asks the user to enter a month name and a year. This can be entered on separate lines.
EG: Enter month: September
Enter year: 2013
The program should then report the number of days in the given month.
A “leap year” is sometimes defined as a year that is divisible by 4. However, more correctly, if the year is divisible by 4 AND divisible by 100, then it is not a leap year.
eg: 1996 -> leap
year (divisible by 4)
This formula is still not complete for the true computation of leap year. Go find a more accurate specification and include it in your program. Be sure to document where you found the more accurate specification.
P2) Tax Calculations
In this day of economic and political uncertainty, there are many different proposals out there for how to tax income. One such proposal is as follows:
The first $30K is tax-free. After that, you can deduct $10K for each dependent. What remains is taxed at the following rates:
Write a program that asks the user for:
The program should report how much tax they owe this year. (both for income and the car combined)