|
-
July 27th, 2010, 12:20 PM
#6
Re: Simple GradeSystem
thank you all so far, made changes
Errors:
Code:
root@bt:~/gradesystem# make gradeSystem
g++ gradeSystem.cpp -o gradeSystem
gradeSystem.cpp: In function 'void writeGrade(int, int)':
gradeSystem.cpp:17: error: 'findLetter' was not declared in this scope
gradeSystem.cpp: In function 'int findLetter()':
gradeSystem.cpp:36: error: 'studentAverage' was not declared in this scope
gradeSystem.cpp:37: error: 'letterGrade' was not declared in this scope
gradeSystem.cpp:37: error: 'A' was not declared in this scope
gradeSystem.cpp:39: error: 'studentAverage' was not declared in this scope
gradeSystem.cpp:40: error: 'letterGrade' was not declared in this scope
gradeSystem.cpp:40: error: 'B' was not declared in this scope
gradeSystem.cpp:42: error: 'studentAverage' was not declared in this scope
gradeSystem.cpp:43: error: 'letterGrade' was not declared in this scope
gradeSystem.cpp:43: error: 'C' was not declared in this scope
gradeSystem.cpp:45: error: 'studentAverage' was not declared in this scope
gradeSystem.cpp:46: error: 'letterGrade' was not declared in this scope
gradeSystem.cpp:46: error: 'D' was not declared in this scope
gradeSystem.cpp:48: error: 'studentAverage' was not declared in this scope
gradeSystem.cpp:49: error: 'letterGrade' was not declared in this scope
gradeSystem.cpp:49: error: 'F' was not declared in this scope
gradeSystem.cpp:51: error: 'letterGrade' was not declared in this scope
gradeSystem.cpp: In function 'void saveError()':
gradeSystem.cpp:56: error: expected primary-expression before 'int'
gradeSystem.cpp:56: error: 'nowTime' was not declared in this scope
gradeSystem.cpp:59: error: 'theTime' was not declared in this scope
gradeSystem.cpp: In function 'int nowTime()':
gradeSystem.cpp:69: error: 'theTime' was not declared in this scope
gradeSystem.cpp: In function 'int main()':
gradeSystem.cpp:90: error: no match for 'operator>>' in 'std::operator>> [with _CharT2 = char, _Traits2 = std::char_traits<char>, _CharT = char, _Traits = std::char_traits<char>](((std::basic_istream<char, std::char_traits<char> >&)(& std::cin)), ((char*)(& studentName))) >> std::endl'
/usr/include/c++/4.3/istream:123: note: candidates are: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>& (*)(std::basic_istream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:127: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:134: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:170: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:174: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:177: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:181: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:184: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:188: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:192: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:197: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:201: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:206: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:210: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:214: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:218: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:242: note: std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/istream:748: note: std::basic_istream<_CharT2, _Traits2>& std::operator>>(std::basic_istream<_CharT2, _Traits2>&, _CharT2*) [with _CharT2 = char, _Traits2 = std::char_traits<char>, _CharT = char, _Traits = std::char_traits<char>]
/usr/include/c++/4.3/bits/istream.tcc:858: note: std::basic_istream<_CharT, _Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&, _CharT&) [with _CharT = char, _Traits = std::char_traits<char>]
gradeSystem.cpp:94: error: expected `)' before ';' token
gradeSystem.cpp:94: error: expected primary-expression before ')' token
gradeSystem.cpp:94: error: expected `;' before ')' token
gradeSystem.cpp:25: error: too few arguments to function 'int theAverage(int, int, int)'
gradeSystem.cpp:105: error: at this point in file
gradeSystem.cpp:13: error: too few arguments to function 'void writeGrade(int, int)'
gradeSystem.cpp:106: error: at this point in file
make: *** [gradeSystem] Error 1
here is the new code:
Code:
#include <iostream>
#include <fstream> // open, read, and write files
//for time
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
void writeGrade(int studentAverage, int letterGrade){
/*
Use the variable gradeAverage to determin the the grade was a A, B, C, D, or F. Then open of the person's file, and write the grade.
*/
findLetter();
ofstream gradeFile;
gradeFile.open ("grades.txt");
gradeFile << "Student: " << studentAverage << endl;
gradeFile << "Grade: " << letterGrade << endl;
gradeFile << "Average: " << studentAverage << endl << endl;
}
int theAverage(int totalAmount, int gradeNumber, int studentAverage){
/*
Here we will average all the numbers together inside of a for loop
*/
studentAverage = totalAmount / gradeNumber;
return studentAverage;
}
int findLetter(){
//take the number and find the letter it is == to
//then store that letter in letterGrade
if ( studentAverage > 95 ){
letterGrade = A;
}
if ( 95 > studentAverage > 85 ){
letterGrade = B;
}
if ( 85 > studentAverage > 80 ){
letterGrade = C;
}
if ( 80 > studentAverage > 69 ){
letterGrade = D;
}
if ( studentAverage < 69 ){
letterGrade = F;
}
return letterGrade;
}
void saveError(){
// save error in log.txt
nowTime(int theTime);
ofstream logFile;
logFile.open ("log.txt");
logFile << "Date: " << theTime << endl;
logFile << "Error: File does not exist or cannot be opened." << endl;
logFile << "Please create file, or create a new file." << endl << endl;
}
int nowTime(){
time_t now;
time(&now);
theTime = "%s", ctime(&now);
return theTime;
}
int main(){
//startup variables that we will use
char studentName[255];
int studentAverage;
int gradeNumber; // amount of student Averages
int totalAmount; //will hold all averages
int submitAmount; //amount submited during for loop session
char letterGrade; // will store the lettergrade before it is written to grades.txt
int theTime; // will hold the current time
bool canWe; // asks if we can continue
// find out who we will be grading
cout << "Hello user!" << endl;
cout << "This program lets you average the grade of your student and write there grade in a text file." << endl;
cout << "Who will be writting a grade for today?" << endl << "Name: ";
cin >> studentName >> endl;
cout << "Ok, we will be grading " << studentName << "today!" << endl;
// make a loop for finding out the average
for ( gradeNumber; canWe == true; gradeNumber++; ){
cout << "Please submit the next grade." << endl << "Grade: ";
cin >> submitAmount;
submitAmount + totalAmount = totalAmount;
cout << "Thank you, the grade has been added." << endl;
cout << "Would you like to add another grade or would you like to quite?" << endl;
cout << "Type 1 to contine or type 2 to quite and press <enter>." << endl << "1 or 0: "; // may need to be switched to true or false
cin >> canWe >> endl;
return totalAmount, gradeNumber;
}
theAverage();
writeGrade();
return 0;
}
Will be working though this myself to see what I can do, but any help is appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|