Write a menu based program to maintain student records. Your program should take
ID: 3566821 • Letter: W
Question
Write a menu based program to maintain student records. Your program should take the
following inputs:
1. Student first name (max. 20 characters)
2. Student last name, (max. 20 characters)
3. Student scores (float/double), eg. 85.4
Your program should be able to take records of a minimum of 5 students and maximum of 15
students.
After taking the records, you should provide 6 functionalities to the user.
1. Print records
Explanation / Answer
#include // std include header std library 002 #include // std include header std input/output 003 #include // std include header for Windows specifics 004 #include /* strcat */ 005 #define STRINGLEN 20 006 /*begin function*/ 007 //define student array stucture 008 struct student{ 009 char studentname[15]; //variable char array[15] - stud_name 010 int studentgrade; //variable float - stud_score 011 }student; //declare student array 012 013 014 015 void gotoxy(int x, int y) { 016 char essq[1000]; /* String variable to hold the escape sequence */ 017 char xstr[1000]; /* Strings to hold the x and y coordinates */ 018 char ystr[1000]; 019 /* Escape sequences must be built with characters */ 020 021 /* 022 ** Convert the screen coordinates to strings 023 */ 024 sprintf(xstr, "%f", x); 025 sprintf(ystr, "%f", y); 026 027 /* 028 ** Build the escape sequence (vertical move) 029 */ 030 essq[0] = ''; 031 strcat(essq, "["); 032 strcat(essq, ystr); 033 034 /* 035 ** Described in man terminfo as vpa=E[%p1%dd 036 ** Vertical position absolute 037 */ 038 strcat(essq, "f"); 039 040 /* 041 ** Horizontal move 042 ** Horizontal position absolute 043 */ 044 strcat(essq, "["); 045 strcat(essq, xstr); 046 /* Described in man terminfo as hpa=E[%p1%dG */ 047 strcat(essq, "G"); 048 049 /* 050 ** Execute the escape sequence 051 ** This will move the cursor to x, y 052 */ 053 //printf("%s", essq); 054 } 055 056 //start main 057 int main(int argc, char *argv[]) 058 { 059 060 struct student studentarray[20];// standard array of structs for student data 061 062 063 char choice; //general choice var sey as char incase of user error input 064 int studentpos = 0; //Student array position var 065 float average = 0; //Average store 066 float min = 100; //Minimun num store 067 float max = 0; //Maximum num store 068 float totalmarks = 0;//Total marks for average 069 070 do{ 071 system("cls"); //C doesnt have a cls, so use dos com 072 fflush(stdin); 073 074 for(studentpos = 0; studentpos < 4; studentpos++)//loop to get user vals 075 { 076 //get student details and fill stucture 077 printf("Please input Student name %d - >", studentpos + 1); 078 //input for student name max length of 20 079 scanf("%s",&studentarray[studentpos].studentname); 080 081 printf(" Please input Student grade - > "); 082 scanf("%2d", &studentarray[studentpos].studentgrade); 083 fflush(stdin); 084 system("cls"); 085 }//for end 086 087 system("cls"); // clear screen 088 089 printf("Student grade statistics "); 090 091 //get the average 092 for(studentpos = 0; studentpos < 4; studentpos++)//loop to get user vals 093 { 094 095 totalmarks += studentarray[studentpos].studentgrade;//calculate the average 096 097 //Max set to 0 and compared. Stores higher num 098 if(studentarray[studentpos].studentgrade > max) 099 { 100 max = studentarray[studentpos].studentgrade;//add if the number is higher 101 }//1 end if 102 103 //Min set to 100 and compared. Store low num 104 if(studentarray[studentpos].studentgradeRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.