Thursday, November 15, 2007

Program 1-23

1. Write a program that will read in two integers and then output their sum, difference and product.

2. Write a program that will accept 4 exams in one term. The program will read in a student's four exam scores as integer and output the student's average. A message will appear "Passed" or "Failed".

3. A Celsius (Centigrade) temperature C can be converted to an equivalent Fahrenheit temperature F according to the following formula: F=(9/5)C + 32 . Write a program that will read in Celsius temperature as decimal number and then output the equivalent Fahrenheit temperature.

4. The straight-line method for computing the yearly depreciation in the value D for an item is given by the formula D=(P-S)/Y where P is the purchase price, S is the salvage value, and Y is the number of years the item is used. Write a program that takes as input the purchase price of an item, its expected number of years of service, and its expected salvage value, and then outputs the yearly depreciation for an item.

5. Write programs that gauge the amount of inflation over the past year. The program asks for the price of an item (such as can goods, hot dog, car etc.) both one year ago and today. It estimates the inflation rate as the difference in the price divided by the last year's price.

6. Write a program to read in weight in pounds and ounces and output the weight expressed in kilograms and grams. One pound equals 0.453592 kilograms. Use a constant declaration.

7. Write a program that read in a distance expressed in kilometers and output the distance expressed in miles. One kilometer equals 0.62137 mile. Use a constant declaration.

8. A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline consumed by the user's car and the number of miles traveled by the car, and then output the number of miles per gallon the car delivered. Use constant declaration.

9. Write a program that determines if a meeting room is in violation of fire regulation for the maximum room capacity. The program will read in the maximum room capacity and the number of people to attend the meeting. If the number of people is less than or equal to the maximum room capacity, the program announces that it is legal to hold a meeting and tells how many additional people may legally attend the meeting. If the number of people exceeds the maximum room capacity, the program announces that the meeting cannot be held as planned due to fire regulations and tells how many people must be excluded in order to meet the fire regulations and thereby allow the meeting to take place.

10. Write a program to list the numbers from 0-25, their squares, and square roots. The output should be in a three-column format. Use the predefined functions sqr and sqrt.
11. Write a program that will convert from dollar to peso or from peso to dollars depending on the user's desire. The user is asked which conversion is to be performed. If the desired conversion is peso to dollar, then the program reads in an amount in peso as well as the peso-to-dollars, then the program reads in an amount in dollars and cents. If the user instead request a conversion from dollar to peso, then the roles of dollars and peso are interchanged. Use at least four procedure or function: one for input, one for output, one to convert from peso to dollars, and one to convent from dollars to peso.

12. Write a program that will read in a length in feet and inches and output the equivalent length in meters and centimeters. Use at least three procedure or function. One for input, one or more for calculating, and one for output. There are 0.3048 meters in a foot, 100 centimeters in a meter, and 12 inches in a foot.

13. The greatest common divisor of two positive integers is the largest integer that divides them both. For example, thr greatest common divisor of 9 and 6 is 3. Write a procedure or function with two integer arguments that returns their greatest common divisor.

14. Write a program to determine grades in a course with three quizzes, each scored on a basis of 10 points. Grades are determined according to the following rule:9 or over is an A;below 9 down to 8 is a B; below 8 down to 7 is a C; below 7 down to 6 is a D and below 6 is an F.

15. Accept two integers and determine if the value are equal, if the values are equal do not print anything, otherwise print the lowest value.

16. Input three unique numbers and print the highest number.

17. Input unique values for n1, n2, and n3 and arrange the numbers in lowest to highest

18. Input four unique numbers and print the difference of the lowest and highest value. If there is equal nos. If it cannot determine the lowest or highest value print “Can not determine the lowest or highest value. Check if there are equal nos.”

19. Accept three integers and identify if there are equal numbers, if there are equal numbers print the equal numbers otherwise do no print anything.

20. Input three integers and determine if there are equal numbers. If there are equal numbers print the product of the equal numbers, otherwise print the average of the numbers.

21. Create a flowchart/program that will accept a child’s age and print its equivalent education level. The age of a child is considered 1 year old if it reaches 6 months. Given the condition of converting 6 months to 1 year, the flowchart/program should be able to identify the Childs education level. If a child was able to finish college, it is considered that he is no longer a child and is already a young adult and a professional. If the educational level is professional, the flowchart/program should not print anything. The education level in relation to the age is as follows: Age 0-2 Parental Age 3-4 Nursery Age 5-6 Pre-School Age 7-12 Elementary Age 13-16 High School Age 17-21 College

23. Make a program that will accept amount and compute the interest for 12 months. Interest is 5% per annum. ans

No comments: