Question: Code goes like: #include /* * askGrade(): * Asks the student for a letter grade * (A = 90-100, B = 80-89, etc.) * then
Code goes like:
#include
/* * askGrade(): * Asks the student for a letter grade * (A = 90-100, B = 80-89, etc.) * then gives the appropriate letter grade in upper case. */ void askGrade() { int grade; printf("Enter your grade:"); scanf("%d", &grade); printf("Your grade is: "); // BEGIN YOUR CODE // TODO: Use if-else statements to print the right letter grade. // END YOUR CODE printf(" "); }
/* * dayOfTheWeek(): * Asks the student for a number, representing the day * of the week (Monday = 1, Tuesday = 2, etc.), * Then prints the name of the day. */ void dayOfTheWeek() { int day; printf("Enter the number of the day of the week:"); scanf("%d", &day); printf("Today is "); // BEGIN YOUR CODE // TODO: Use switch statements to print the right letter grade. // END YOUR CODE printf(" "); }
int main(void) { // Call the first method askGrade(); dayOfTheWeek(); return 0; }
---------------------------------------------------------------------------
The objective of this exercise is to practice using conditionals
There are two sections of code you have to write, they are enclosed like this:
\\ BEGIN YOUR CODE
\\ TODO: Description of the task
\\ END YOUR CODE
The first section is in the askGrade() method. You have to use If-Else statements to check the range of a grade and assign it a letter grade:
-
A = 90-100
-
B = 80-89
-
C = 70-79
-
D = 60-69
-
F = 0-59
-
ERROR, otherwise
You only have to print out the right letter using printf().
----------------------------------------------------
The second section is in the dayOfTheWeek() method. You have to use a Switch statement to print out the right day of the week:
-
Monday = 1
-
Tuesday = 2
-
Wednesday = 3
-
Thursday = 4
-
Friday = 5
-
Saturday = 6
-
Sunday = 7
-
ERROR, for all other numbers
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
