please do as much as you can of this question. i will still give you a high rati
ID: 3624380 • Letter: P
Question
please do as much as you can of this question. i will still give you a high rating. and you will get the karma points
The following information is in a text file for each of the students in a course. Each line of the input file contains a single record. Each field is separated by a comma (comma separated values) in the following order with the given limitations:
• Given name (64 characters or less)
• Family name (64 characters or less)
• Student ID (9 digits or less)
• Midterm (an integer in the range 0-100)
• Final Exam (an integer in the range 0-100)
• Assignment #1 (an integer in the range 0-100)
• Assignment #2 (an integer in the range 0-100)
• Assignment #3 (an integer in the range 0-100)
• Assignment #4 (an integer in the range 0-100)The grading policy is as follows:
• Midterm 30%
• Final Exam 50%
• Assignments 20% (equal weight each)
Numeric grades are converted to letter grades using the following table:
Average Grade
90+ A
80 to < 90 B
70 to < 80 C
60 to < 70 D
<60 F
Requirements:
1. The main program must be in a file called A4.cpp
2. The data must be read in from a data file. The user must enter the filename. A sample
data file will be provided on Moodle. Sample output must be provided using this file.
3. The program must be able to handle a variable number of records. However, the
number of records should not exceed 200. If the number of records exceed this, the
program must display a single error message and ignore the rest of the records.
4. All data from the file must be stored in arrays. The assignment data must be stored in a multi-dimensional array.
5. The program must validate all data and generate error messages if the record is
malformed or data is not within specification. The error message should indicate
which record is malformed (i.e. the line number) and what is wrong with the record.
The program will then continue to process the rest of the file ignoring the bad record.
6. Your code should be modular, using a variety of functions. At least one function must return a value, another must modify data in arrays and another must be a void
function. Your code will contain far more then these three, however, these three types must exist.
7. The program will sort the data by student ID. You can use an insertion or selection
sort.
8. The source code used to sort the data must be stored in files sort.cpp and sort.h
9. Calculate the average assignment grade, numeric course grade and letter grade. These values are to be stored in arrays. The letter grade is to be an array of enum values.
10. The program will output the sorted data in a tabular format in the following order:
1. Student ID
2. Student's name (Given and family name)
3. Midterm
4. Average assignment grade
5. Final exam
6. Numeric course grade (2 decimal places)
7. Letter grade The last row of the table should contain the average values for the midterm, assignments, final exam and numeric course grade.
11. After displaying the table the user should be prompted to enter a student ID. If the ID is valid, display all the information (data from the file and calculated values) about the student. Use a binary search to locate the student's information. If the record is not found, display an error message. Allow the user to continue to lookup most students until they choose to exit.
12. The source code used to search the data must be stored in files search.cpp and
search.h
Your code should be modular, well constructed and make extensive use of functions. All user input should be tested for validity. Make proper use of constants.
Explanation / Answer
please rate - thanks
all I have time for
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int input(string[],string[],string[],int[],int[],int[],int[],int[],int[],int,int&);
int decode(string&,string,int& ,char,int,int,string);
int decode(int&,string,int& ,char,int,int,int,string);
int findend(int,string,char);
int main()
{
string last[200],first[200],id[200];
int mid[200],final[200],a1[200],a2[200],a3[200],a4[200];
int i,max=200,n=0;
if(input(last,first,id,mid,final,a1,a2,a3,a4,max,n)!=0)
{cout<<"file did not open please check it ";
system("pause");
return 0;
}
system("pause");
return 0;
}
int input(string last[],string first[],string id[],int mid[],
int final[],int a1[],int a2[],int a3[],int a4[],int max,int& n)
{ char filename[30];
cout<<"what is the name of the file you are using? ";
cin>>filename;
ifstream in;
in.open(filename); //open file
if(in.fail()) //is it ok?
return 1;
int upto,good,m=0;
string buffer;
getline(in,buffer);
while(in)
{upto=0;
good+=decode(first[n],buffer,upto,',',64,m,"first name");
good+=decode(last[n],buffer,upto,',',64,m,"last name");
good+=decode(id[n],buffer,upto,',',9,m,"id");
good+=decode(mid[n],buffer,upto,',',0,100,m,"midterm");
good+=decode(final[n],buffer,upto,',',0,100,m,"final");
good+=decode(a1[n],buffer,upto,',',0,100,m,"assignment 1");
good+=decode(a2[n],buffer,upto,',',0,100,m,"assignment 2");
good+=decode(a3[n],buffer,upto,',',0,100,m,"assignment 3");
good+=decode(a4[n],buffer,upto,'',0,100,m,"assignment 4");
if(good==9)
n++;
m++;
getline(in,buffer);
}
in.close();
return 0;
}
int decode(string& s,string b,int &upto,char a,int max,int m,string mess)
{int i,end;
end=findend(upto,b,a);
i=end-upto;
s=b.substr(upto,i);
upto=end+1;
if(end-upto>max)
{cout<<"record "<<m<<" "<<mess<<" has > "<<max<<" characters ";
return 1;
}
return 0;
}
int decode(int& n,string b,int &upto,char a,int min,int max,int m,string mess)
{ int i,end;
string s;
end=findend(upto,b,a);
i=end-upto;
s=b.substr(upto,i);
n=atoi(s.c_str());
upto=end+1;
if(n<min||n>max)
{cout<<"record "<<m<<" "<<mess<<" out of range ";
return 1;
}
return 0;
}
int findend(int upto,string b,char a)
{return b.find(a,upto);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.