6.9 Programming Exercises

I l @ ve RuBoard

Exercise 6-1: A professor generates letter grades using Table 6-3.

Table 6-3. Grade values

% Correct

Grade

0-60

F

61-70

D

71-80

C

81-90

B

91-100

A

Write a program that accepts a numeric grade and displays the corresponding letter grade.

Exercise 6-2: Modify the previous program to print out a + or - after the letter grade based on the last digit of the score. The modifiers are listed in Table 6-4.

Table 6-4. Grade-modification values

Last digit

Modifier

1-3

-

4-7

<blank>

8-0

+

For example, 81=B-, 94=A, and 68=D+. Note that an F is only an F; there is no F+ or F-.

Programmers frequently have to modify code that someone else wrote. A good exercise is to take someone else's Exercise 6-2 and modify it.

Exercise 6-3: Given an amount less than $1.00, compute the number of quarters , dimes, nickels, and pennies needed.

Exercise 6-4: A leap year is any year divisible by 4 unless it is divisible by 100, but not 400. Write a program to tell whether a year is a leap year.

Exercise 6-5: Write a program that, given the number of hours an employee worked and her hourly wage, computes her weekly pay. Count any hours over 40 as overtime at time-and-a-half.

I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net