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

You are responsible for tracking the progress of a junior-high fundraiser. You d

ID: 3890917 • Letter: Y

Question

You are responsible for tracking the progress of a junior-high fundraiser. You decide to make a program which will help you with the task.

Make a console program where you will implement variables that are needed for this program and will implement the code entirely within Main.

Prompt the user for contributions. It should first ask for the contributor's grade.

You should then it should ask how much the student is contributing.

These prompts should be placed inside of a loop so that the program will continue to ask for contributions until a value of 999 is entered for the contributor's grade.

Once that value is entered, the program should calculate the average value of the contributions.

Display the results, with a congratulatory message for the class which collected the largest amount.

Use a Boolean variable to control the while loop

Use a switch statement to help get the input into the proper variables

Place the switch statement within the while loop and use the Boolean variable to control the loop and set its value to false when the sentinel value (999) is detected.

When calculating the averages you will need a selection statement for each grade contribution to either compute the individual grade contribution average or to set it to zero if there were no contributions for that grade.

Explanation / Answer

\ C program

#include<stdio.h>

void main() {
float total_A=0.000,p,q,r,s,total_C = 0.000,total_B=0.000;
int x[999],y[999],z[999],i,j=0,k=0,l=0;
bool flag=1;
char grade;
  
for(i=0;i<999;i++)
{
printf(" In which grade you are ? A / B / C ");
scanf(" %c",&grade);
  
if(grade=='a' || grade=='A')
{
while(flag==1)
{
if(i==999)
{
flag = 0;
break;
}
else
{
printf(" How much contribution you are going to do ?");
scanf(" %d",&x[j]);
total_A += x[j];
j++;
  
}

}
  
}
else if(grade=='b' || grade=='B')
{
while(flag==1)
{
if(i==999)
{
flag = 0;
break;
}
else
{
printf(" How much contribution you are going to do ?");
scanf(" %d",&y[k]);
total_B += y[k];
k++;
}

}
  
}
  
else if(grade=='c' || grade=='C')
{
while(flag==1)
{
if(i==999)
{
flag = 0;
break;
}
else
{
printf(" How much contribution you are going to do ?");
scanf(" %d",&z[l]);
total_C += z[l];
l++;
}

}
  
}
}
p= total_A/j;
q= total_B/k;
r=total_C/l;
s =(p+q)/2;
printf(" total average contribution is %f :",s);

if( total_A>=total_B && total_A>=total_C )
printf("%f is the max contribution done by A grade", total_A);

if( total_B>=total_A && total_B>=total_C )
printf("%f is the max contribution done by B grade", total_B);

if( total_C>=total_A && total_C>=total_C )
printf("%f is the max contribution done by C grade", total_C);

}

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