i need help with two confusing errors

The first one i have no idea whats wrong
1
2
cout<<"Please Enter Student Name:     "<<endl;
	cin>>student_name[30];


error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::istream' (or there is no acceptable conversion)


the second one is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
avg = (Num_Ans/5)*100;
		if((avg >= 90)&&(avg<=100))
	 cout<<"Your grade is an A"<<endl;

	 else if ((avg >= 80)&&(avg<=89))
	cout<<"Your grade is a B"<<endl;

	 else if ((avg >= 70)&&(avg<=79))
	 cout<<"Your grade is a C"<<endl;

	else if ((avg >= 60)&&(avg<=69))
	 cout<<"Your grade is a D"<<endl;
 
	else if ((avg >= 0)&&(avg<=59))
	 cout<<"Your grade is a F"<<endl;

the error message says ecpected a deffinition on all of the if and else if lines

I have never experienced either one of these problems before and i have baffled by them
Thanks for any help
What is the type of student_name?

The second is probably something before that, could you post the whole code section there.

here is the whole code the first error was 37 and the second was 104

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include <iostream>
#include <string>
#include <iomanip>

the first error was line 37

using namespace std;
double avg;

struct StudentRecord
{
	int ID;
	string student_name[30];
	string name;
	char letter_grade;
};

struct Answers
{
	char answer1;
	char answer2;
	char answer3;
	char answer4;
	char answer5;
};

struct key
{
	char key1;
	char key2;
	char key3;
	char key4;
	char key5;
};

void getInformation(StudentRecord student_name[],int& ID)
{
	cout<<"Please Enter Student Name:     "<<endl;
	cin>>student_name[30];
	cout<<"Please Enter Student Id Number "<<endl;
	cin>>ID;

	cout<<"Please enter the student's answer to question 1: "<<endl;
	cin>>Answers.answer1;
	cout<<"Please enter the students's answer to question 2: "<<endl;
	cin>>Answers.answer2;
	cout<<"Please enter the student's answer to question 3: "<<endl;
	cin>>Answers.answer3;
	cout<<"Please enter the student's answer to question 4: "<<endl;
	cin>>Answers.answer4;
	cout<<"Please enter the studen's answer to question 5: "<<endl;
	cin>>Answers.answer5;
}




void entKey ()
{
	cout<<"Please enter the answer to question 1: "<<endl;
	cin>>key.key1;
	cout<<"Please enter the answer to question 2: "<<endl;
	cin>>key.key2;
	cout<<"Please enter the answer to question 3: "<<endl;
	cin>>key.key3;
	cout<<"Please enter the answer to question 4: "<<endl;
	cin>>key.key4;
	cout<<"Please enter the answer to question 5: "<<endl;
	cin>>key.key5;
}
void calculateAvgAndLetter(StudentRecord student[], int number_of_students, char[])
{	int cal1,cal2,cal3,cal4,cal5;
char lttrgrade;
	
	if (Answers.answer1 = key.key1)
			cal1=1
		else 
		cal1=0;
		
	if (Answers.answer2 = key.key2)
			cal2=1;
		else 
		cal2=0;
		
	if (Answers.answer3 = key.key3)
			cal3=1;
		else 
		cal3=0;
		
	if  (Answers.answer4 = key.key4)
			cal4=1;
		else 
			cal4=0;
		
	if (Answers.answer5 = key.key5)
			cal5=1;
		else 
			cal5=0;
	}

	double Num_Ans = cal1+cal2+cal3+cal4+cal5;
	
	double score= Num_Ans;

	double avg = (Num_Ans/5)*100;
		if((avg >= 90)&&(avg<=100))
	 cout<<"Your grade is an A"<<endl;

	 else if ((avg >= 80)&&(avg<=89))
	cout<<"Your grade is a B"<<endl;

	 else if ((avg >= 70)&&(avg<=79))
	 cout<<"Your grade is a C"<<endl;

	else if ((avg >= 60)&&(avg<=69))
	 cout<<"Your grade is a D"<<endl;
 
	else if ((avg >= 0)&&(avg<=59))
	 cout<<"Your grade is a F"<<endl;







int main()
{


return 0;
}
cin do not know how to put info to your struct
1
2
3
4
void getInformation(StudentRecord student_name[],int& ID)
{
	cout<<"Please Enter Student Name:     "<<endl;
	cin>>student_name[30];


You cant do like this
cin>>Answers.answer1;
it can be
cin>>answer1;
but here will be same problem as in first error.

In line 74 you forgot ";"

And everywhere same problem Answers.answer1
Answers is not an object it is type name.
All your code is a mess :S

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
double Num_Ans = cal1+cal2+cal3+cal4+cal5;
	
	double score= Num_Ans;

	double avg = (Num_Ans/5)*100;
		if((avg >= 90)&&(avg<=100))
	 cout<<"Your grade is an A"<<endl;

	 else if ((avg >= 80)&&(avg<=89))
	cout<<"Your grade is a B"<<endl;

	 else if ((avg >= 70)&&(avg<=79))
	 cout<<"Your grade is a C"<<endl;

	else if ((avg >= 60)&&(avg<=69))
	 cout<<"Your grade is a D"<<endl;
 
	else if ((avg >= 0)&&(avg<=59))
	 cout<<"Your grade is a F"<<endl;



:D :D :D
1
2
3
4
5
6
int main()
{


return 0;
}


your main function :D :D :D
Last edited on
Topic archived. No new replies allowed.