Somebody help me please!

I feel like a mindless dumb ass =/

Okay I'm completely stuck in this part
---If P is pressed, display the content of an array - make sure you display all registered students. Do not terminate the program. After displaying students, you should prompt the user with the menu again. If there are no registered students, you should prompt the message: No registered students!--

When I get to store the student's info into the array and then when the program loops back to the menu and I press P to display the array nothing comes out :(
This is my first time taking C++ and I get very confused when it comes to structures and arrays.
any help? advice?

And also I'm supposed to write a function that allows me to drop certain student by name. That I'm completely clue less. Somebody please help me out! I've been going through hell and back.

Thanks!
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
 
//Alejandro Lopez
 
#include <iostream>
#include <string>

using namespace std;

struct Student{

		string name;
		char sex;
		char finalGrade;
		double gpa;
		
};

void showMenu(){
   
	cout<< "-------------------------------" << endl;
	cout<<"Welcome to the COP1334 Student Registration System!\n";
	cout<<"To register a student enter A.\n";
	cout<<"To print all registered students enter P.\n";
	cout<<"To drop a student enter D.\n";
	cout<<"To quit this program enter Q.\n";
	
}
void displayRecords(Student& cop){
	      
    cout << "Student Name: " << cop.name << endl;
    cout << "Student Sex: " << cop.sex << endl;
    cout << "Course Final Grade: " << cop.finalGrade << endl;
    cout << "Course GPA: " << cop.gpa << endl;
	cout << endl;
}

//void dropStudent() I need help with this function
int main(){
	
	const int SIZE = 2;
	
	Student cop[SIZE];

	char option;
	
	do{

	showMenu();
	cin>>option;
   
	if (option == 'A'){
		for (int n = 0; n < SIZE; n++){
      
			cout<< "Enter Student Name: ";
			cin>> cop[n].name;
		
			cout<< "Enter Student Sex: ";
			cin>> cop[n].sex;

			cout<< "Enter Student Final Grade: ";
			cin>> cop[n].finalGrade;
		
			cout<< "Enter Student GPA: ";
			cin>> cop[n].gpa;
			cout<< endl;
		}	
	}else if(option == 'P'){
			
		for(int i = 0; i < SIZE; i++){
			
			displayRecords(cop[i]);
		
			 }
		} 

	}while (option != 'Q');
   
   return 0;
	
}
You should convert user input to uppercase. For example, if the user enters lowercase 'p', nothing willl happen because none of your if statemnts evaluate to true with a lowercase p.

try adding this option = toupper(option); after you input the option variable.
Last edited on
Topic archived. No new replies allowed.