Student Enrollment

Student Enrollment

Introduction:

This lab will introduce students to control logic programming concepts usingAutoIT.

  • Allow the user to enter a degree acronym. The input is valid only for the BA, BSC, BIS or BBA programs. If the user enters a different degree program, (e.g. MMS, PhD) your program should do no calculations nor display any data. Instead, the program should display an error message, such as below and then terminate.

INVALID DEGREE PROGRAM – PLEASE ENTER A NEW DEGREE PROGRAM

If a valid degree acronym is entered, the display should be customized for that particular degree (e.g., for the BIS program, the algorithm displaysthe header: Department of Information Systems and for the BA program the header should display: Bachelors of Arts, etc.).

The program accepts as input from the user, data regarding enrollment in a university degree program.

  • The # of students in Year 1
  • The # of students in Year 2
  • The # of students in Year 3
  • The # of students in Year 4
  • The # of students in Year 5
  • The # of students in Year 6

And display as a report:

  • The name of the report.
  • The number of students in each year.
  • The percentage enrollment for each year.
  • The total number of students in the degree.
  • For each year, if the enrollment is over the limit for that particular year write a message indicating that the number of students enrolled in that particular year is over the limit.

Also, each Year has an enrollment limit. Year 1 to Year 6: Maximum enrollment is 80

Solution 

#include<stdio.h>

#include<stdlib.h>

#include<string.h>

#include<math.h>

int main(intargc, char* argv[])

{

chardeg[100];

intfirst_year, second_year, third_year, fourth_year, fifth_year, sixth_year;

floatpercentage_first_year, percentage_second_year, percentage_third_year, percentage_fourth_year, percentage_fifth_year, percentage_sixth_year;

inttotal_student;

intBA_flag, BSC_flag, BIS_flag, BBA_flag;

BA_flag = 0;

BSC_flag = 0;

BIS_flag = 0;

BBA_flag = 0;

printf(“\n Please enter your degree name\n”);

scanf(“%s”, deg);

if(strcmp(deg,”BA”) == 0)

{

BA_flag = 1;

//printf(“\nBachelors of Arts\n”);

}

else if (strcmp(deg,”BSC”) == 0)

{

BSC_flag = 1;

//printf(“\nBachelors of Science\n”);

}

else if (strcmp(deg,”BIS”) == 0)

{

BIS_flag = 1;

//printf(“\nDepartment of Information Systems\n”);

}

else if (strcmp(deg,”BBA”) == 0)

{

BBA_flag = 1;

//printf(“\nBachelor of Business Administration\n”);

}

else

{

printf(“\nINVALID DEGREE PROGRAM – PLEASE ENTER A NEW DEGREE PROGRAM\n”);

exit(0);

}

printf(“\n Please enter the number of students in Year 1\n”);

scanf(“%d”, &first_year);

printf(“\n Please enter the number of students in Year 2\n”);

scanf(“%d”, &second_year);

printf(“\n Please enter the number of students in Year 3\n”);

scanf(“%d”, &third_year);

printf(“\n Please enter the number of students in Year 4\n”);

scanf(“%d”, &fourth_year);

printf(“\n Please enter the number of students in Year 5\n”);

scanf(“%d”, &fifth_year);

printf(“\n Please enter the number of students in Year 6\n”);

scanf(“%d”, &sixth_year);

if(BA_flag == 1)

{

printf(“\n======Department of Bachelors of Arts======\n”);

}

else if(BSC_flag == 1)

{

printf(“\n======Department of Bachelors of Science======\n”);

}

else if(BIS_flag == 1)

{

printf(“\n======Department of Information Systems======\n”);

}

else if(BBA_flag == 1)

{

printf(“\n======Department of Bachelor of Business Administration======\n”);

}

printf(“\nThe number of students in year 1 is %d\n”, first_year);

printf(“\nThe number of students in year 2 is %d\n”, second_year);

printf(“\nThe number of students in year 3 is %d\n”, third_year);

printf(“\nThe number of students in year 4 is %d\n”, fourth_year);

printf(“\nThe number of students in year 5 is %d\n”, fifth_year);

printf(“\nThe number of students in year 6 is %d\n”, sixth_year);

total_student = first_year + second_year + third_year + fourth_year + fifth_year + sixth_year;

percentage_first_year = ((float)first_year/(float)total_student) * 100;

percentage_second_year = ((float)second_year/(float)total_student) * 100;

percentage_third_year = ((float)third_year/(float)total_student) * 100;

percentage_fourth_year = ((float)fourth_year/(float)total_student) * 100;

percentage_fifth_year = ((float)fifth_year/(float)total_student) * 100;

percentage_sixth_year = ((float)sixth_year/(float)total_student) * 100;

printf(“\nThe percentage number of students in year 1 is %f\n”, percentage_first_year);

printf(“\nThe percentage number of students in year 2 is %f\n”, percentage_second_year);

printf(“\nThe percentage number of students in year 3 is %f\n”, percentage_third_year);

printf(“\nThe percentage number of students in year 4 is %f\n”, percentage_fourth_year);

printf(“\nThe percentage number of students in year 5 is %f\n”, percentage_fifth_year);

printf(“\nThe percentage number of students in year 6 is %f\n”, percentage_sixth_year);

if(first_year> 80)

{

printf(“\n The number of students enrolled in year 1 is over the limit \n”);

}

if(second_year> 80)

{

printf(“\n The number of students enrolled in year 2 is over the limit \n”);

}

if(third_year> 80)

{

printf(“\n The number of students enrolled in year 3 is over the limit \n”);

}

if(fourth_year> 80)

{

printf(“\n The number of students enrolled in year 4 is over the limit \n”);

}

if(fifth_year> 80)

{

printf(“\n The number of students enrolled in year 5 is over the limit \n”);

}

if(sixth_year> 80)

{

printf(“\n The number of students enrolled in year 6 is over the limit \n”);

}

return 1;

}