First of all hello everyone Im a first year Computer Engineer.Because of my English pres Exam I started university 3 weeks late and I missed a lot of things. This is my first homework and I really need help .Im thinking about using if statement
So my homework is to write a program that user will enter his/her student ID and program will show the year, faculty name, department name and student no. Assume that all students are registered after 2000. The number is 10 digit for example if your student I’d is 1801023100 output will be Year:2018 Faculty:Faculty of Engineering Department:Computer Engineering Student no :3100 There are 8 faculties and a lot of departments How can I write this program please help I have 5 days left
#include <iostream>
usingnamespace std;
struct Student
{
string ID;
int year;
string faculty;
string department;
int studentNo;
};
// Reads the data for a student
Student read_student()
{
Student s;
cout << "Enter ID: "; cin >> s.ID;
cout << "Enter year: "; cin >> s.year;
cout << "Enter faculty: "; cin >> s.faculty;
cout << "Enter department: "; cin >> s.department;
cout << "Enter studentNo: "; cin >> s.studentNo;
return s;
}
int main();
{
// Getting some student's data from console:
vector<Student> student_v;
while (true)
{
cout << "Do you want enter the data of another student? (y/n) ";
string input;
getline(cin, input);
if (input[0] == 'y' || input[0] == 'Y')
{
Student s = read_student;
student_v.push_back(s);
}
else
{
break; // breaks out the while loop
}
}
// finding students by ID;
while (true)
{
string input;
cout << "Do you want to seach a student by ID? (y/n)\n";
getline( cin, input);
if (input[0] == 'n' || input[0] == 'N') break; // outbreak from while
cout << "Enter an ID: "
getline( cin, input);
bool student_found = false; // A flag which gets true if a student was found.
for( Student & s : student_v)
{
if (s.ID == input)
{
cout << "Year:"<<s.year
<< " Faculty:"<<s.faculty
<<" Department: "<<s.department
<<" Student no:" << s.studentNo
<< '\n';
student_found = true;
break; // A student was found, so we can abort the for-loop.
}
}
if (student_found == false) cout << "Sorry no student which this ID found.\n";
}
}