Please can you figure out the problem because it keeps say Invalid Credit when I chose 2?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Please can you figure out the problem because it keeps say Invalid Credit when I chose 2?

 

#include<iostream>
#include<string.h>
using namespace std;

struct student
{
int number;
string name;
int age;
string city;
}s[10];

struct module
{
int number;
string name;
string code;
int credit;
}m[10];

struct assessment
{
int number;
int marks1;
int marks2;
}a[10];

int index1 =0, index2=0, index3=0;

void StudentRegistration()
{
if(index1==10)
{
cout<<"No more data can be added"<<endl;
return;
}
string temp;
cout<<"Enter personal data"<<endl;
cout<<"Enter Student Number"<<endl;
cin>>s[index1].number;
cout<<"Enter Student Name"<<endl;
getline(cin, temp);
getline(cin,s[index1].name);
cout<<"Enter Age"<<endl;
cin>>s[index1].age;
cout<<"Enter city"<<endl;
getline(cin,temp);
getline(cin,s[index1].city);
index1++;
}

void ModuleEnrolment(int id)
{
if(index2==10)
{
cout<<"No more data can be added"<<endl;
return;
}
m[index2].number = id;
string temp;
int c;
getline(cin, temp);
cout<<"Enter Module 1 Name"<<endl;
getline(cin,m[index2].name);
cout<<"Enter Module 1 Code"<<endl;
getline(cin,m[index2].code);
cout<<"Enter Module 1 Credit"<<endl;
while(true)
{
cin>>c;
if(c!=15 && c!=30)
{
cout<<"Invalid Credit"<<endl;
}
else
{
m[index2].credit=c;
break;
}
}
index2++;
}

void StudentAssessment(int id)
{
if(index1==10)
{
cout<<"No more data can be added"<<endl;
return;
}
m[index3].number = id;
cout<<"Enter Module 1 marks"<<endl;
cin>>a[index3].marks1;
cout<<"Enter Module 2 marks"<<endl;
cin>>a[index3].marks2;
index3++;
}

void display(int id, int option)
{
if(option==1)
{
for(int i=0;i<index1;i++)
{
if(s[i].number == id)
{
cout<<"Personal Information"<<endl;
cout<<"Student Number "<<s[i].number<<endl;
cout<<"Student Name "<<s[i].name<<endl;
cout<<"Student Age "<<s[i].age<<endl;
cout<<"Student City "<<s[i].city<<endl;
return;
}
}
cout<<"Student ID not Found"<<endl;
}
else if(option==2)
{
for(int i=0;i<index2;i++)
{
if(m[i].number == id)
{
cout<<"Module Information"<<endl;
cout<<"Module 1 Name "<<m[i].name<<endl;
cout<<"Module 1 Code "<<m[i].code<<endl;
cout<<"Module 1 Credit "<<m[i].credit<<endl;
return;
}
}
cout<<"Student ID not Found"<<endl;
}
else if(option==3)
{
for(int i=0;i<index3;i++)
{
if(s[i].number == id)
{
cout<<"Assessment Information"<<endl;
cout<<"Module 1 marks "<<a[i].marks1<<endl;
cout<<"Module 2 marks "<<a[i].marks2<<endl;
return;
}
}
cout<<"Student ID not Found"<<endl;
}
}

int main()
{
cout<<"**************************************"<<endl;
cout<<"*Welcome to Student Management System*"<<endl;
cout<<"**************************************"<<endl;
int choice;
while(true)
{
cout<<"1- Student Registration"<<endl;
cout<<"2- Module Enrollment"<<endl;
cout<<"3- Student Assessment"<<endl;
cout<<"4- Search Student"<<endl;
cout<<"5.Exit"<<endl;
cout<<"Enter your choice (1-5): "<<endl;
cin>>choice;
if(choice == 1)
{
StudentRegistration();
cout<<"Student Information is added"<<endl;
}
else if(choice == 2)
{
int id;
cout<<"Enter Student ID: "<<endl;
cin>>id;
ModuleEnrolment(id);
cout<<"Modules Enrolled"<<endl;
}
else if(choice == 3)
{
int id;
cout<<"Enter Student ID: "<<endl;
cin>>id;
StudentAssessment(id);
cout<<"Assessment Added"<<endl;
}
else if(choice == 4)
{
int id,option;
cout<<"Enter Student ID: "<<endl;
cin>>id;
cout<<"Enter search Option"<<endl;
cout<<"1.Personal data search"<<endl;
cout<<"2.Module Search"<<endl;
cout<<"3.Assessment Search"<<endl;
cin>>option;
display(id,option);
}
else if(choice ==5)
{
break;
}
else
{
cout<<"Invalid Choice"<<endl;
}
}
}

4– Search Student
5.Exit
Enter your choice (1-5):
2
Enter Student ID:
144
Enter Module 1 Name
sarah
Enter Module 1 Code
16
Enter Module 1 Credit
14
Invalid Credit
20
Invalid Credit
10
Invalid Credit
10
Invalid Credit
18
Invalid Credit
Transcribed Image Text:4– Search Student 5.Exit Enter your choice (1-5): 2 Enter Student ID: 144 Enter Module 1 Name sarah Enter Module 1 Code 16 Enter Module 1 Credit 14 Invalid Credit 20 Invalid Credit 10 Invalid Credit 10 Invalid Credit 18 Invalid Credit
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY