-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment2.cpp
48 lines (39 loc) · 1.01 KB
/
Assignment2.cpp
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
#include <iostream>
using namespace std;
int main()
{
//declare variables
string arr[5][3];
string name;
string name_check;
string id;
string grade;
//Use for loop and 2d array to input all the stuff and store it
for (int i = 0; i < 5; i++)
{
cout << "Type name: ";
cin >> name;
cout << "Type in the id: ";
cin >> id;
cout << "Type in the grade: ";
cin >> grade;
for (int k = 0; k < 1; k++)
{
arr[i][k] = name;
arr[i][k + 1] = id;
arr[i][k + 2] = grade;
}
}
//Check info by searching 2d array with the name
cout << "Enter a name to check: ";
cin >> name_check;
for (int l = 0; l < 5; l++)
{
if (arr[l][0] == name_check)
{
cout << "Name: " << arr[l][0] << endl;
cout << "ID: " << arr[l][1] << endl;
cout << "Grade: " << arr[l][2] << endl;
}
}
}