Question: #include float total(float,float,float); int units; int main() { int ch,c0ch1;//c0ch1 is the cases integer variable,ch is the choice for selecting session float enrollmentfee,studentservicesfee,stickerfee, idCardfee,parkingfee,totalfee; char

#include

float total(float,float,float); int units; int main() { int ch,c0ch1;//c0ch1 is the cases integer variable,ch is the choice for selecting session float enrollmentfee,studentservicesfee,stickerfee, idCardfee,parkingfee,totalfee; char choice; // it is for selecting yes or no i.e. y or n; printf("Hello world! "); printf("enter units "); scanf("%i", &units); printf("Is this Fall[0], Winter[1], Spring[2] or Summer[3] session "); scanf("%i", &ch); switch(ch) { case 0://for Fall printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=19; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=85; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; case 1:// for winter printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=16; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=45; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; case 2:// for spring printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=19; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=85; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; case 3:// for summer printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=16; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=45; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; default: printf("please enter correct option "); } return 0; } float total(float enroll,float park,float service) { enroll=enroll*units; printf("%f\t%f\t%f ", enroll, park, service); return (enroll+park+service); }

Why does this code not work? #include float total(float,float,float); int units; int main() { int ch,c0ch1;//c0ch1 is the cases integer variable,ch is the choice for selecting session float enrollmentfee,studentservicesfee,stickerfee, idCardfee,parkingfee,totalfee; char choice; // it is for selecting yes or no i.e. y or n; printf("Hello world! "); printf("enter units "); scanf("%i", &units); printf("Is this Fall[0], Winter[1], Spring[2] or Summer[3] session "); scanf("%i", &ch); switch(ch) { case 0://for Fall printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=19; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=85; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; case 1:// for winter printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=16; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=45; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; case 2:// for spring printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=19; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=85; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; case 3:// for summer printf("Are you a state resident[0] or not[1]: "); scanf("%i", &c0ch1); studentservicesfee=16; if(c0ch1==0) { enrollmentfee=46; } else if(c0ch1==1) { enrollmentfee=335; } printf("Want a parking decal? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { parkingfee=45; } else if(choice=='n' || choice=='N') { parkingfee=0; } printf("Want an AS sticker? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { stickerfee=19.5; studentservicesfee+=stickerfee; } else if(choice=='n' || choice=='N') { stickerfee=0; studentservicesfee+=stickerfee; } printf(" Want an ID card? [y/n]: "); scanf(" %c", &choice); if(choice=='y' || choice=='Y') { idCardfee=13; studentservicesfee+=idCardfee; } else if(choice=='n' || choice=='N') { idCardfee=0; studentservicesfee+=idCardfee; } totalfee=total(enrollmentfee,parkingfee,studentservicesfee); printf("For Fall semester, your total fees are :\t%.2f ", totalfee); break; default: printf("please enter correct option "); } return 0; } float total(float enroll,float park,float service) { enroll=enroll*units; printf("%f\t%f\t%f ", enroll, park, service); return (enroll+park+service); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!