hello everyone, Probably a really basic question, but I am still begging here and can't seem to figure it out..
My teacher is asking me to create a program that takes students marks, converts them into percent and outputs a letter grade.. That part is all fine and dandy but the part I don't understand is that she says, "Initialize letter grades and weightings from a file" Now I know how to I/O from files, but correct me if I am wrong, you can't really input a range? like if the file said an A was from 80 to 90 percent.. Any help would be greatly appreciated. thanks
#include <iostream>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <fstream>
usingnamespace std;
struct Grade{ //a struct to store grades with min-max value for range
string desc;
int min;
int max;
};
vector<Grade> grades;
int main(){
ifstream input("ListGrades.txt",ios::in);
Grade temp_grade;
while(input.good())
input >> temp_grade.desc >> temp_grade.min >> temp_grade.max;
grades.insert(temp_grade);
}
//------- other code --------
}
//if the number of grades is known and the file contains all of them, you can use this variant
Grade grades[NUM_GRADES]
int main(){
ifstream input("ListGrades.txt",ios::in);
for(int i=0;i<NUM_GRADES;i++) input>>grades[i].desc>>grades[i].min>>grades[i].max;
//-------- other code --------
}