Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Anna Cowsar
- //CS 1428 Fall 2015 Project #3
- //Last updated:10/11/2015
- #include <iostream>
- #include <iomanip>
- #include <fstream>
- using namespace std;
- int main()
- {
- //declaring variables
- string name, address, ssn, telephone, Course;
- int age, years;
- double weight1 = .1; //different test weights
- double weight2 = .15;
- double weight3 = .15;
- double weight4 = .2;
- double finalweight = .4;
- char A_SCORE = 65; //variables for determining the letter grade
- char B_SCORE = 66;
- char C_SCORE = 67;
- char D_SCORE = 68;
- char F_SCORE = 70;
- int numStudents;
- int numTests = 5;
- int numCourses = 3;
- //variables for the test grades
- double Test1, Test2, Test3, Test4, FinalExam, LetterGrade;
- //opening an input file
- ifstream fin;
- fin.open ("Project3_A04367115_Input.txt");
- //creating an output file and opening it
- ofstream fout;
- fout.open ("Project3_A04367115_Output.txt");
- //heading of the output file
- cout << "Enter the number of students you wish to see information from: ";
- cin >> numStudents;
- for (int j = 0; j < numStudents; ++j)
- {fout << setw(48) << "Student Grade Sheet \n";
- fout << "\t Department of Computer Science, Texas State University, San Marcos" << endl;
- //reading from the input and printing to the output
- fout << right << setw(35) << "Name of Student: ";
- getline(fin, name);
- fout << left << "\t" << name << endl;
- fout << right << setw(35) << "Age: ";
- fin >> age;
- fin.ignore();
- fout << left << "\t" << age << endl;
- fout << right << setw(35) << "Address: ";
- getline(fin, address);
- fout << left << "\t" << address << endl;
- fout << right << setw(35) << "Number of years at Texas State: ";
- fin >> years;
- fin.ignore();
- fout << left << "\t" << years << endl;
- fout << right<< setw(35) << "Telephone Number: ";
- getline(fin, telephone);
- fout << left << "\t" << telephone << endl;
- fout << right << setw(35) << "Student Soc. Security #: ";
- getline(fin, ssn);
- fout << left << "\t" << ssn << endl;
- for (int j = 1; j < numCourses; ++j)
- { fout << right << setw(35) << "Course Number: ";
- fin >> Course;
- fin.ignore();
- fout << left << "\t" << Course << endl;
- for (int k=1; k < numTests; ++k)
- {
- fout << right << setw(32) << "Test #" << k << ": ";
- fin >> Test1;
- fin.ignore();
- fout << right << "\t" << showpoint << fixed << setprecision(1) << Test1 << endl;
- }
- fout << right << setw(35) << "Final Exam: ";
- fin >> FinalExam;
- fout << left << "\t" << fixed << setprecision(1) << FinalExam << endl;
- fin.ignore();
- //calculating the student's final grade
- double FinalGrade = (Test1 * weight1) + (Test2 * weight2) + (Test3 * weight3) + (Test4 * weight4)
- + (FinalExam * finalweight);
- fout << right << setw(35) << "Numerical Grade: " << left << "\t" << FinalGrade << endl;
- //if statements for determining the student's letter grade
- fout << right << setw(35) << "Letter Grade: ";
- if (FinalGrade >= A_SCORE)
- {
- fout << "\t" << A_SCORE << endl;
- }
- else if (FinalGrade >= B_SCORE)
- {
- fout << "\t" << B_SCORE << endl;
- }
- else if (FinalGrade >= C_SCORE)
- {
- fout << "\t" << C_SCORE << endl;
- }
- else if (FinalGrade >= D_SCORE)
- {
- fout << "\t" << D_SCORE << endl;
- }
- else
- {
- fout << "\t" << F_SCORE << endl;
- }
- }}
- fout << "\t Course Instructor is Kelly Princeton, professor, Department of Computer Science Texas State University, San Marcos, TX 78666";
- //closing files
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement