
K. Dzwonkiewicz
Using
Switch... with function calls
This program will determine a
letter grade for a student or students.
:
Ask the class name.
:
Ask the student’s name.
:
Ask the student’s test
grade (as a float).
:
Ask the student’s sex
(use only two choices please... M or F)
:
Have a class average in
a constant (assume it is from last year’s test for the comparable class).
:
Enter the student’s age.
Use a switch to branch on the
percent)Hint the operator of switch must be an integer or char, so maybe do
something like this... switch) floor(score)/l0).
If the person is a Male they
get a 2% bonus (of course)
If they are over 21 they get
a 2% bonus (senior citizen)
If they are Female they get a
5% reduction) for legal reasons from a former court settlement)
If they are under 10 years
old they get a 8% reduction) for being precocious)
After you ask all the
questions, call two functions...
(
agepoints=Get_agebonus()
and
sexpoints=Get_sexbonus() , where you return the age bonus points
and
the sex bonus points
)
Switch( floor(score)/l0)
{
case l0:
case 9: letter grade=’A’;
break;
…}
Have it ask questions like
this...
Please enter the name of
the class. . .Frene tic
Please enter your name... Vanilla Ice
Please enter your test score for Vanilla Ice.. .86.5
Please enter Vanilla Ice’s
..... .14
Please
enter Vanilla Ice’s ..... .27