Free Essay

Ghdfgrdyre

In:

Submitted By famaay
Words 977
Pages 4
Exercise 2
Write outputs, inputs and draw flowcharts for the solutions of following problems:
1. Write a program that asks the user to enter a number within the range of 1 through 10. Then display the Roman numeral version of that number.
2. The date June 10, 1960 is special because when we write it in the following format, the month times the day equals the year. 6/10/60. Write a program that asks the user to enter a month (in numeric form), a day, and a two-digit year. The program should then determine whether the month times the day is equal to the year. If so, it should display a message saying the date is magic. Otherwise it should display a message saying the date is not magic.
3. Write a program that calculates and displays a person’s body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person’s BMI is calculated with the following formula:
BMI = weight x 703 / height2 where weight is measured in pounds and height is measured in inches. The program should display a message indicating whether the person has optimal weight, is underweight, or is overweight. A sedentary person’s weight is considered to be optimal if his or her BMI is between 18.5 and 25. If the BMI is less than 18.5, the person is considered to be underweight. If the BMI value is greater than 25, the person is considered to be overweight.
4. Write a program that asks the user to enter a number of seconds. There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds. There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days in that many seconds.
5. Write a program that can be used as a math tutor for a young student. The program should display two random numbers that are to be added, such as:
247
+ 129
--------
The program should wait for the student to enter the answer. If the answer is correct, a message of congratulations should be printed. If the answer is incorrect, a message should be printed showing the correct answer.
6. A software company sells a package that retails for $99. Quantity discounts are given according to the following table.
Quantity Discount
10–19 20%
20–49 30%
50–99 40%
100 or more 50%
Write a program that asks for the number of units sold and computes the total cost of the purchase.
7. A bank charges $10 per month plus the following check fees for a commercial checking account:
$.10 each for fewer than 20 checks
$.08 each for 20–39 checks
$.06 each for 40–59 checks
$.04 each for 60 or more checks
The bank also charges an extra $15 if the balance of the account falls below $400 (before any check fees are applied). Write a program that asks for the beginning balance and the number of checks written. Compute and display the bank’s service fees for the month.
8. A bug collector collects bugs every day for seven days. Design a program that keeps a running total of the number of bugs collected during the seven days. The loop should ask for the number of bugs collected for each day, and when the loop is finished, the program should display the total number of bugs collected.
9. Running on a particular treadmill you burn 3.9 calories per minute. Design a program that uses a loop to display the number of calories burned after 10, 15, 20, 25, and 30 minutes.
10. Design a program that asks the user to enter the amount that he or she has budgeted for a month. A loop should then prompt the user to enter each of his or her expenses for the month, and keep a running total. When the loop finishes, the program should display the amount that the user is over or under budget.
11. At one college, the tuition for a full-time student is $6,000 per semester. It has been announced that the tuition will increase by 2 percent each year for the next five years. Design a program with a loop that displays the projected semester tuition amount for the next five years.
12. The distance a vehicle travels can be calculated as follows:
Distance = Speed × Time
For example, if a train travels 40 miles per hour for three hours, the distance traveled is 120 miles. Design a program that asks the user for the speed of a vehicle (in miles per hour) and how many hours it has traveled. It should then use a loop to display the distance the vehicle has traveled for each hour of that time period. Here is an example of the output:
What is the speed of the vehicle in mph? 40 [Enter]
How many hours has it traveled? 3 [Enter]
Hour Distance Traveled
—————————————
1 40
2 80
3 120
13. Design a program that displays a table of the Celsius temperatures 0 through 100 and their Fahrenheit equivalents. The formula for converting a temperature from Celsius to Fahrenheit is
F = (9/5)C + 32 where F is the Fahrenheit temperature and C is the Celsius temperature. Your program must use a loop to display the table.

Similar Documents