Lost!!!!!

I have been trying to write this program and i have no idea what i am doing. I don't understand alot of the C++ language. I just know the basic stuff. So if some one could help me that would be great!!!! I will give you the program later
Last edited on
How can we help when you don't tell us anything?
i was just going to see if someone could

ok well here is m program
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

// Function Protoype
void displayResults(int SS, string FN[], string LN[], char CA[], char AN[], double TP, double TPR, double percent, char grade);
void calculateGrade ();

int main ()
{
calculateGrade();

return 0;
}



// Function Definition


void calculateGrade ()
{

// Declare Arrays
int menuChoice = 0;
string FN[20] = {""};
string LN[20] = {""};
int SS = 0;
char RG = ' ';
int TP = 20;
double TPR = 0;
int i = 0;
double percent = 0.0;
char grade = ' ';
int points, points1, points2, points3, points4, points5, points6, points7, points8, points9 = 0;
char AN[10] = {' '} ;
char t, f = ' ' ;
char CA[10] = {t,f,f,t,f,f,f,f,t,f} ;
char A, B, C, D, F = ' ';

system("cls");

// Prompt User for information
do
{
cout << "1 - Enter Student Information";
cout << "2 - Chapter 13 Quiz";
cout << "3 - Grade Chapter 13 Quiz";
cout << "4 - Exit Program";

cout << "Please enter Menu Choice (1-4) and press enter";
cin >> menuChoice;

if (menuChoice == 1)
{
cout << "Please enter First Name: ";
cin >> FN[i];
cout << "Please enter Last Name: ";
cin >> LN[i];
cout << "Please enter Social Security: ";
cin >> SS;
}
else if (menuChoice == 2)
{
cout << "Please use lower case for following questions" <<endl;

cout << "t or f: A double type is an example of a simple data type: " ;
cin >> AN[0];
cout << "t or f: A function can return a value of type array: " ;
cin >> AN[1];
cout << "t or f: A variable name can't be passed to a value parameter: " ;
cin >> AN[2];
cout << "t or f: A value-returning function returns only one value " ;
cin >> AN[3];
cout << "t or f: tThe instance variables of a class must be of the same type: " ; cin >> AN[4];
cout << "t or f: The member functions of a class must be public: " ;
cin >> AN[5];
cout << "t or f: The results of a logical expression can't be assigned to a bool variable: " ;
cin >> AN[6];
cout << "t or f: in C++, both ! and != are logical expressions: " ;
cin >> AN[7];
cout << "t of f: The function ignore is used to skip certain input in a line: " ; cin >> AN[8];
cout << "t or f: A C++ identifier can start with a digit; " ;
cin >> AN[9];
}
else if (menuChoice == 3)
{
if (AN[0] == CA[0])
{
points = 2;
}
else
{
points = 0;
}
if (AN[1] == CA[1])
{
points1 = 2;
}
else
{
points1 = 0;
}
if (AN[2] == CA[2])
{
points2 = 2;
}
else
{
points2 = 0;
}
if (AN[3] == CA[3])
{
points3 = 2;
}
else
{
points3 = 0;
}
if (AN[4] == CA[4])
{
points4 = 2;
}
else
{
points4 = 0;
}
if (AN[5] == CA[5])
{
points5 = 2;
}
else
{
points5 = 0;
}
if (AN[6] == CA[6])
{
points6 = 2;
}
else
{
points6 = 0;
}
if (AN[7] == CA[7])
{
points7 = 2;
}
else
{
points7 = 0;
}
if (AN[8] == CA[8])
{
points8 = 2;
}
else
{
points8 = 0;
}
if (AN[9] == CA[9])
{
points9 = 2;
}
else
{
points9 = 0;
}
TPR = points + points1 + points2 + points3 + points4 + points5 + points6 + points7 + points8 + points9;
percent = TPR / TP;


if (percent >= .90)
{
grade = A;
}
if ((percent < .90) && (percent >= .80))
{
grade = B;
}
if ((percent < .80) && (percent >= .70))
{
grade = C;
}
if ((percent < .70) && (percent >= .60))
{
grade = D;
}
else (percent < .60);
{
grade = F;
}
}
else (menuChoice == 4);
{
return 1;
}
while (i <= 20);
}
}

displayResults (SS, FN, LN, CA, AN, TP, TPR, percent, grade);

void displayResults(int SS , string FN[] , string LN[] , char CA[], char AN[], double TP , double TPR, double percent, char grade);
{
//Declare variables
string hyphens = " ";
int i = 0;

hyphens.assign(79, '-');

// Display Results headings
cout << hyphens << endl;
cout << left;
cout << setw(10) << "Social Security Number" << setw(10) << "First Name" << setw(15) << "Last Name" << setw(8) << "Correct Answer" << setw(8) <<"Student's Answer" << setw(8) <<"Right/Wrong" << setw(8) << "Total Points" << setw(8) << "Total Points Recieved" << setw(8) << "Percent" << setw(8) << "Grade";

do
{
cout << "T or F: A double type is an example of a simple data type: " ;
cout << "T or F: A function can return a value of type array: " ;
cout << "T or F: A variable name can't be passed to a value parameter: " ;
cout << "T or F: A value-returning function returns only one value " ;
cout << "T or F: The instance variables of a class must be of the same type: " ;
cout << "T or F: The member functions of a class must be public: " ;
cout << "T or F: The results of a logical expression can't be assigned to a bool variable: " ;
cout << "T or F: in C++, both ! and != are logical expressions: " ;
cout << "T of F: The function ignore is used to skip certain input in a line: " ;
cout << "T or F: A C++ identifier can start with a digit; " ;
cout << setw(15) << SS << " " << FN[i] << " " << LN[i] << " " << CA[i] << " " << AN[i] << " " << TP << " " << TPR << " " << percent << " " << grade << " " << endl;
i++;
}
while (i >= 20);
}


}
Here is what i have to do

write a program that allows 20 students to take a quiz(one person at a time)
use two functions
use one array
have a main menu that displays:
1 - students information
2 - chapter quiz
3 - grade
4 - exit program

i put the question on there

i have to display everything
the full name
SS number
the quetions
the right anwswers
what the student answered
if they got the question right
how many points they got( each quetions is worth 2 points)
there percent
and the letter grade they got
Okay well, get started on that and come back when you have problems, please. We aren't going to do it for you.
i put the program on there
What problems are you having with it?
here are my errors i don't know what they mean

------ Build started: Project: QuizProgram, Configuration: Debug Win32 ------
Compiling...
QuizProgram.cpp
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(51) : error C2059: syntax error : 'do'
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(52) : error C2143: syntax error : missing ';' before '{'
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(52) : error C2447: '{' : missing function header (old-style formal list?)
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(211) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(211) : error C2365: 'displayResults' : redefinition; previous definition was 'function'
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(13) : see declaration of 'displayResults'
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(211) : error C2078: too many initializers
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(214) : error C2447: '{' : missing function header (old-style formal list?)
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(245) : error C2059: syntax error : '}'
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(245) : error C2143: syntax error : missing ';' before '}'
f:\documents\cs 121\quizprogram\quizprogram\quizprogram.cpp(245) : error C2059: syntax error : '}'
Build log was saved at "file://f:\Documents\CS 121\QuizProgram\QuizProgram\Debug\BuildLog.htm"
QuizProgram - 10 error(s), 0 warning(s)
ok so i rewrote the program it is working but the percent is coming out as zero i dunno way

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main ()
{
//Declare Variables
int menuChoice = 0;
int i = 0;
string FN = " ";
string LN = " ";
char AN[10] = {' '};
char f = ' ';
char t = ' ';
char CA[10] = {'f','f','t','f','f','f','f','t','f','t'};
int SS = 0;
int p, p1, p2, p3, p4, p5, p6, p7, p8, p9 = 0;
int TP = 20;
int TPR = 0;
double percent = 0.0;
char A,B,C,D,F = ' ';
char grade = ' ';

do
{

top:
system ("cls");

cout << "1 - Enter Student Information" << endl;
cout << "2 - Chapter 13 Quiz" << endl;
cout << "3 - Grade Chapter 13 Quiz" << endl;
cout << "4 - Exit Program" << endl;

cout << "Please enter your choice: ";
cin >> menuChoice;

if (menuChoice == 1)
{

cout << "Please enter First Name: ";
cin >> FN[i];
cout << "Please enter Last Name: ";
cin >> LN[i];
cout << "Please enter Social Security: ";
cin >> SS;
goto top;
}
else if (menuChoice == 2)
{

cout << "First name " << FN << endl;
cout << "Last name " << LN << endl;
cout << "Social Security Number " << SS << endl;
cout << "Please use lower case for following questions" <<endl;

cout << "t or f: A double type is an example of a simple data type: " ;
cin >> AN[0];
cout << "t or f: A function can return a value of type array: " ;
cin >> AN[1];
cout << "t or f: A variable name can't be passed to a value parameter: " ;
cin >> AN[2];
cout << "t or f: A value-returning function returns only one value " ;
cin >> AN[3];
cout << "t or f: tThe instance variables of a class must be of the same type: " ;
cin >> AN[4];
cout << "t or f: The member functions of a class must be public: " ;
cin >> AN[5];
cout << "t or f: The results of a logical expression can't be assigned to a bool variable: " ;
cin >> AN[6];
cout << "t or f: in C++, both ! and != are logical expressions: " ;
cin >> AN[7];
cout << "t of f: The function ignore is used to skip certain input in a line: " ;
cin >> AN[8];
cout << "t or f: A C++ identifier can start with a digit; " ;
cin >> AN[9];

goto top;
}

else if (menuChoice == 3)
{

if (AN[0] == CA[0])
{
p = 2;
}
else
{
p = 0;
}
if (AN[1] == CA[1])
{
p1 = 2;
}
else
{
p1 = 0;
}
if (AN[2] == CA[2])
{
p2 = 2;
}
else
{
p2 = 0;
}
if (AN[3] == CA[3])
{
p3 = 2;
}
else
{
p3 = 0;
}
if (AN[4] == CA[4])
{
p4 = 2;
}
else
{
p4 = 0;
}
if (AN[5] == CA[5])
{
p5 = 2;
}
else
{
p5 = 0;
}
if (AN[6] == CA[6])
{
p6 = 2;
}
else
{
p6 = 0;
}
if (AN[7] == CA[7])
{
p7 = 2;
}
else
{
p7 = 0;
}
if (AN[8] == CA[8])
{
p8 = 2;
}
else
{
p8 = 0;
}
if (AN[9] == CA[9])
{
p9 = 2;
}
else
{
p9 = 0;
}

TPR = p + p1 + p2 + p3 + p4 + p5 + p6 + p7 + p8 + p9;
percent = TPR / 20;

if (percent >= .90)
{
grade = 'A';
}
if ((percent < .90) && (percent >= .80))
{
grade = 'B';
}
if ((percent < .80) && (percent >= .70))
{
grade = 'C';
}
if ((percent < .70) && (percent >= .60))
{
grade = 'D';
}
else (percent < .60);
{
grade = 'F';
}

cout <<" First name: " << FN << endl;
cout << "Last name: " << LN << endl;
cout << "Social Security Number: " << SS << endl;
cout << "Total Points: " << TPR << endl;
cout << "Percent: " << percent << endl;
cout << "Grade: " << grade << endl;
cout << "Students Answers: " << AN[0] << endl;
cout << "Students Answers: " << AN[1] << endl;
cout << "Students Answers: " << AN[2] << endl;
cout << "Students Answers: " << AN[3] << endl;
cout << "Students Answers: " << AN[4] << endl;
cout << "Students Answers: " << AN[5] << endl;
cout << "Students Answers: " << AN[6] << endl;
cout << "Students Answers: " << AN[7] << endl;
cout << "Students Answers: " << AN[8] << endl;
cout << "Students Answers: " << AN[9] << endl << endl;
cout << "Correct Answers: " << CA[0] << endl;
cout << "Correct Answers: " << CA[1] << endl;
cout << "Correct Answers: " << CA[2] << endl;
cout << "Correct Answers: " << CA[3] << endl;
cout << "Correct Answers: " << CA[4] << endl;
cout << "Correct Answers: " << CA[5] << endl;
cout << "Correct Answers: " << CA[6] << endl;
cout << "Correct Answers: " << CA[7] << endl;
cout << "Correct Answers: " << CA[8] << endl;
cout << "Correct Answers: " << CA[9] << endl;
cout << "Go back to menu?: ";
cin >> menuChoice;

if (menuChoice == 1)
{
goto top;
}
if (menuChoice == 2)
{
goto top;
}
if (menuChoice == 3)
{
goto top;
}
if (menuChoice == 4)
{
return 1;
}

}
}
while (i >= 20);

if (menuChoice == 4)
{


return 1;

}



return 0;

}
 
percent = TPR / 20;


Should be to get a result.:

 
percent = TPR / 20.0;


But in the case of a getting a % i think you'd want:

 
percent = (TPR / 20.0) * 100;
Thanks!!! that worked!!!
but what does it mean by this:

f:\documents\cs 121\quizprogram3\quizprogram3\quizprogram3.cpp(28) : warning C4101: 'B' : unreferenced local variable

f:\documents\cs 121\quizprogram3\quizprogram3\quizprogram3.cpp(28) : warning C4101: 'C' : unreferenced local variable

f:\documents\cs 121\quizprogram3\quizprogram3\quizprogram3.cpp(28) : warning C4101: 'A' : unreferenced local variable

f:\documents\cs 121\quizprogram3\quizprogram3\quizprogram3.cpp(28) : warning C4101: 'D' : unreferenced local variable



Also the grade is coming out an f every time
You declared four char variables, A, B, C, D, but I don't see you using them. That's probably what's generating that warning.
i used them in the if statments for percent
No, you didn't. You assigned char literals to grade, not the variables A, B, C, D, F themselves. F is probably generating no warning because you initialized it.

I think I know what you want to do.

Change the declaration line to:
 
char A = 'A', B = 'B', C = 'C', D = 'D', F = 'F';


And then change the if statements to:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
if (percent >= 0.90)
{
    grade = A;
}
else if (percent >= 0.80)     // Less than 0.90
{
    grade = B;
}
else if (percent >= 0.70)     // Less than 0.80
{
    grade = C;
}
else if (percent >= 0.60)     // Less than 0.70
{
    grade = D;
}
else                          // Less than 0.60
{
    grade = F;
}
Last edited on
Oh i see, thanks
closed account (S6k9GNh0)
No! Don't do that! If your going to use a char for that reason, there's no reason to use them at all! The reason to hold a character is so it can change variably, not hold a constant character. If that were the case, then character variables would be almost useless.
Thank everyone, I got it to work and the out put is coming out right!!
Topic archived. No new replies allowed.