Question

How design a C program to calculate the tuition payable by its students. The program should...

How design a C program to calculate the tuition payable by its students. The
program should accept the students Id number, name, Programme being persued and the programme
Year (1, 2, OR 3) the student is in, and the students GPA (NB* First year students start with a GPA of
0 and the program is to programmatically insert this value). The regular tuition fee for all students is
$175,000.00. However, a discount is given to every student whose GPA falls within a certain range,
based on whether the student is in Year 1, Year 2, OR Year 3, as follows:
Year GPA Discount
1 0 0%
2 2.7 to 4.0 10%
3 3.2 to 4.0 15%
The program is to calculate the final tuition amount, and display the students’ name, Id number,
programme being persued, regular tuition, discount amount and final tuition amount, for each student
processed. After each student is processed, the system should give the user an option to process
another.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the program for your question in C Programming Language.

CODE :(filename.c)

#include<stdio.h>

int main()
{
   //Variables decleration
   int studentId,year;
  
   char studentName[100],programme[100],choice[3];
  
   float GPA;
  
   double tutionFee ;
  
   //do while to ask user, after completeing one student record, to continue or not
      
   do{
   tutionFee = 175000;
   //Reading values from user
   printf("Welcome to ABC Tution System");
  
   printf("\nPlease enter student's Id number : ");
  
   scanf("%d",&studentId);
  
   printf("\nPlease enter student's name : ");
  
   scanf("%s",studentName);
  
   printf("\nPlease enter student's programme : ");
  
   scanf("%s",programme);
  
   printf("\nPlease enter student's year : ");
  
   scanf("%d",&year);
  
   //validations for year
   do{
  
       if(year == 1)
       {
           GPA = 0.0;
       }
       else if(year == 2 || year == 3)
       {
           printf("\nPlease enter student's GPA : ");
           scanf("%f",&GPA);
           while(GPA < 0 || GPA > 5.00)
           {
               printf("Invalid GPA entered...Please enter GPA again");
               scanf("%f",&GPA);
           }
          
       }
       else
       {
           printf("Invalid Year value given...Please enter year again(Only 1 or 2 or 3)");  
           scanf("%d",&year);
               printf("\nPlease enter student's GPA : ");
           scanf("%f",&GPA);
           while(GPA < 0 || GPA > 5.00)
           {
               printf("Invalid GPA entered...Please enter GPA again");
               scanf("%f",&GPA);
           }
          
       }
   }while(year!=1 &&year !=2 && year !=3);
  
   //Calculating tution fee
   if(year == 2)
   {
       if(GPA >=2.7 && GPA <= 4.0)
       {
           tutionFee = 175000 - (175000 * (0.1));
       }
   }
   else if(year == 3)
   {
       if(GPA >=3.2 && GPA <= 4.0)
       {
           tutionFee = 175000 - (175000 * (0.2));
       }
   }
  
   //Printing details
   printf("\n\n The tution fee details of the student are :\n\nStudent ID : %d\nStudent Name : ",studentId);
  
   puts(studentName);
  
   printf("Programe Pursuing : %s",programme);
  
  
   printf("\nYear : %d\nGPA : %.1f\nRegular Fee : $175,000.00",year,GPA);
  
   if(year == 2)
   {
       if(GPA >=2.7 && GPA <= 4.0)
       {
           printf("\nDiscount : 10%% \nFinal Tution Fee : %.2lf",tutionFee);
       }
       else
       {
           printf("\nDiscount : 0%% \nFinal Tution Fee : %.2lf",tutionFee);
       }
   }
   else if(year == 3)
   {
       if(GPA >=3.2 && GPA <= 4.0)
       {
           printf("\nDiscount : 20%% \nFinal Tution Fee : %.2lf",tutionFee);
       }
           else
       {
           printf("\nDiscount : 0%% \nFinal Tution Fee : %.2lf",tutionFee);
       }
   }
   else
   {
           printf("\nDiscount : 0%% \nFinal Tution Fee : %.2lf",tutionFee);
   }
   printf("\nDo you want to get another student's fee ?(Y/N)");
   scanf("%s",choice);
   }while(strcmp(choice,"y")==0 || strcmp(choice,"Y")==0);
   return 0;
}

SCREENSHOTS

OUTPUT

If wrong input given

NOTE : As I have used scanf for reading strings please be careful while giving names of student and program , make sure they do not contain spaces if they contain spaces the second string after space will be taken as next variable value.

Any doubts can be explained with pleasure :)

Add a comment
Know the answer?
Add Answer to:
How design a C program to calculate the tuition payable by its students. The program should...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT