Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How would questions 5 and 6 be answered? C statements Read the following code. F

ID: 3870646 • Letter: H

Question


How would questions 5 and 6 be answered? C statements

Read the following code. For each of the provided example values of category that might be entered by a user indicate the final values for rate and total. 5. int rate = 20; double total 100.0; char category printf Enter the letter of your category: "; scanf(" %c", &category;: switch (category) case ‘m' : rate = rate + 1; case ‘F' : total = rate * 2; break; ‘H' : "D,: case (int) (total)/8); rate= break; case default total total rate; break; Final value of total is: Sample value for category Final value of rate is: M* H' 6. Write a comparable if-else statement for the switch statement above (just start at the beginning of switch)

Explanation / Answer

5.

Category

Rate

Total

M

21

42

H

12

100

G

20

120

6.

#include<stdio.h>

int main()
{
int rate = 20;
total = 100;
char category ;
scanf("%c",&category);
  
if(category=='M')
{
rate++;
total = rate * 2;
}
else if(category=='F')
{
total = rate * 2;
}
else if(category=='H'||category=='D')
{
rate=(int)(total/8);
}
else
total+=rate;

}

Category

Rate

Total

M

21

42

H

12

100

G

20

120

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote