Please write the code in java or C Assignment Coding the Stu
Please write the code in java or C.
Assignment: Coding the Student Profile Program
The assignment is to implement the Student Profile Program following the “requirements” listed in the Specification section below. The goal of this assignment is to write this application as “tight” as possible, meaning without run-time or logical errors.
The application must compile for credit to be received.
The Student Profile Program logs student information to an external file. The system must allow for the entry of multiple students. The information that is recorded for each student in the log is the following:
1. Full name
2. Age
3. TUID Number
4. Email Address
5. Phone Number
6. Major
7. Expected graduation date
8. Is the student an Undergraduate?
The Application is to have a simple user interface that allows the user to input the following and only the following:
1. Last Name
2. First Name
3. Middle Name
4. Date of Birth
5. Phone Number
6. Expected Graduation Date
7. TUID
8. Email Address
9. Major
10. Whether the student is an undergraduate or not.
Student data will be written to an external file in a presentable manner. Simply listing each student’s information separated by a blank line between students is acceptable.
The application does not have to allow for editing of student information once it has been submitted.
Solution
// C code
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <assert.h>
#include <string.h>
int main()
{
int num;
FILE *fptr;
fptr = fopen(\"output.txt\",\"w\");
if(fptr == NULL)
{
printf(\"Error!\");
exit(1);
}
int total;
printf(\"Enter total number of students: \");
scanf(\"%d\",&total);
char lastName[20];
char firstName[20];
char middleName[20];
char dateofBirth[20];
char phoneNumber[20];
char expectedGraduationDate[20];
char TUID[20];
char emailAddress[20];
char Major[20];
char undergrad[2];
fprintf(fptr, \"FULL Name\\tAGE\\tTUID NUMBER\\tEmail Address\\tPHONE NUMBER\\tMAJOR\\tEXPECTED GRADUATION DATE\\tIS THE STUDENT AN UNDERGRADUATE?\ \");
for (int i = 1; i <= total; ++i)
{
printf(\"\ Enter details of student %d\ \",i);
printf(\"Enter last name: \");
scanf(\"%s\",lastName);
printf(\"Enter first name: \");
scanf(\"%s\",firstName);
printf(\"Enter middle name: \");
scanf(\"%s\",middleName);
printf(\"Enter date of borth: \");
scanf(\"%s\",dateofBirth);
printf(\"Enter phone number: \");
scanf(\"%s\",phoneNumber);
printf(\"Enter expected graduation date: \");
scanf(\"%s\",expectedGraduationDate);
printf(\"Enter TUID: \");
scanf(\"%s\",TUID);
printf(\"Enter email Address: \");
scanf(\"%s\",emailAddress);
printf(\"Enter the Major: \");
scanf(\"%s\",Major);
printf(\"IS the student undergrad?(y/n): \");
scanf(\"%s\",undergrad);
int age = 16 + 100 - (10* (dateofBirth[strlen(dateofBirth)-2]-\'0\') + (dateofBirth[strlen(dateofBirth)-1]-\'0\'));
fprintf(fptr, \"%s %s %s\\t%d\\t%s\\t%s\\t%s\\t%s\\t%s\\t%s\ \",firstName,middleName,lastName,age,TUID,emailAddress,phoneNumber,Major,expectedGraduationDate,undergrad);
}
//fprintf(fptr,\"%d\",num);
fclose(fptr);
return 0;
}
/*
output:
Enter total number of students: 3
Enter details of student 1
Enter last name: clarke
Enter first name: km
Enter middle name: mic
Enter date of borth: 31/12/1992
Enter phone number: 675727282
Enter expected graduation date: 21/7/2017
Enter TUID: 34
Enter email Address: mailmail@mail.com
Enter the Major: CSSE
IS the student undergrad?(y/n): y
Enter details of student 2
Enter last name: kin
Enter first name: kad
Enter middle name: mile
Enter date of borth: 2/2/1995
Enter phone number: 5666433334
Enter expected graduation date: 21/4/2018
Enter TUID: 55
Enter email Address: knkad@mail.com
Enter the Major: ME
IS the student undergrad?(y/n): n
Enter details of student 3
Enter last name: trw
Enter first name: sde
Enter middle name: fin
Enter date of borth: 3/12/1998
Enter phone number: 45333333
Enter expected graduation date: 3/2/2017
Enter TUID: 43
Enter email Address: trw@mail.com
Enter the Major: RE
IS the student undergrad?(y/n): n
output.txt:
FULL Name AGE TUID NUMBER Email Address PHONE NUMBER MAJOR EXPECTED GRADUATION DATE IS THE STUDENT AN UNDERGRADUATE?
km mic clarke 24 43 mailmail@mail.com 675727282 CSSE 21/7/2017 y
kad mile kin 21 55 knkad@mail.com 5666433334 ME 21/4/2018 n
sde fin trw 18 34 trw@mail.com 45333333 RE 3/2/2017 n
*/


