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

Learning Outcomes: 1) if/else statements 2) switch Your C program for the follow

ID: 3744774 • Letter: L

Question

Learning Outcomes: 1) if/else statements 2) switch Your C program for the following problem should run exactly as shown in the sample runs, including format and indentation. Name your .c file as project2.c Your C program must include a switch statement in addition to if/else statements) At Valence community college, a student can take up to two courses. The purpose of this assignment is to construct a fee invoice for a student. This requires the input of Student's id as an integer and (up to the two course numbers as integers. It costs 120.25 dollars per credit hour in addition to $35.00 charged for health and id services. Here 13 the list of all courses offered at Valence Community College: CRN 4587 4599 8997 9696 Course Prefix MAT 236 COP 220 GOL 124 COP 100 Credit Hours After inputting all the necessary data (see sample runs below), a fee invoice 13 printed to the screen when the data entered 13 valid VALENCE COMMUNITY COLLEGE ORLANDO FL 10101 Fee Invoice Prepared for Student VEE5 1 Credit Hour 120.25 CRN 4587 4599 CREDIT HOURS $ 481.00 s 360.75 Health & id fees 35.00 Total payments 876.75

Explanation / Answer

#include<stdio.h>
#include<string.h>
int convert(char *del)
{
int num=0,i,len=strlen(del);
del=strrev(del);
for(i=len-1;i>=0;i--)
{
num=num*10+(del[i]-48);
}
return num;
}
int main(){
int i,id,choice,ncourse,val;
float credit_hour=120.25,total=0.0;
char courses[9];
printf("Enter the student's Id: ");
scanf("%d",&id);
printf("Enter how many courses taken (up to 2) : ");
scanf("%d",&ncourse);
if(ncourse==2){
printf("Enter the 2 course numbers separated by - :(like 2356-8954) ");
scanf("%s",courses);
printf("Thank you! ");
printf("PRESS ANY KEY TO CONTINUE . . . ");
getch();
printf(" VALENCE COMMUNITY COLLEGE ");
printf(" ORLANDO FL 10101 ");
printf(" ************************* ");
printf(" Fee Invoice Prepared for Student V%d ",id);
printf(" 1 Credit Hour = $%f ",credit_hour);
printf(" CRN CREDIT HOURS ");
char* del = strtok(courses,"-");
while(del!=NULL){
val=convert(del);
switch(val){
case 4587:
printf(" 4587 4 %f ",credit_hour*4);
total=total+credit_hour*4;
break;
case 4599:
printf(" 4599 3 %f ",credit_hour*3);
total=total+credit_hour*3;
break;
case 8997:
printf(" 8997 1 %f ",credit_hour*1);
total=total+credit_hour*1;
break;
case 9696:
printf(" 9696 3 %f ",credit_hour*3);
total=total+credit_hour*3;
break;
}
del = strtok(NULL,"-");
}
printf(" Health & id fees $35.00 ");
printf(" --------------------------------------- ");
printf(" Total Payments $%0.2f",total+35);

} else if(ncourse==0){
printf(" Thank you! ");
printf("PRESS ANY KEY TO CONTINUE . . . ");
getch();
printf(" VALENCE COMMUNITY COLLEGE ");
printf(" ORLANDO FL 10101 ");
printf(" ************************* ");
printf(" Fee Invoice Prepared for Student V%d ",id);
printf(" Health & id fees $35.00 ");
printf(" --------------------------------------- ");
printf(" Total Payments $%0.2f",total+35);

} else{
printf(" Sorry, we can't process your request this time-invalid number of course.");
printf(" Try again, Goodbye!");
}
return 0;
}

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