In: Computer Science
In this Pluralsight Lab, you will continue viewing the course C++ Fundamentals Including C++ 17 by Kate Gregory. Note that in this lab, some concepts are covered that we will cover in class later in the course. However, Having a introduction to these concepts will definitely aid in your understanding later in the course. Also, the application created in this lab will be used in subsequent Pluralsight labs.
You may access the course by following this link: https://app.pluralsight.com/library/courses/cplusplus-fundamentals-c17/table-of-contents
Instructions
Begin this lab by viewing the following modules in the Pluralsight course:
Then complete the following tasks:
C++
You may access the course by following this link: https://app.pluralsight.com/library/courses/cplusplus-fundamentals-c17/table-of-contents
and it have free trial for 4 days I thin you can access
Status.h
#include <iostream>
using namespace std;
#pragma once
enum Status{Attending,nonAttending,Graduated};
Student.h
#include<iostream>
#include<string>
#include "Status.h"
#pragma once
using namespace std;
class Student{
private:
int studentId;
string firstName;
string lastName;
public:
Status studentStatus;
Student();
Student(int a,string b,string c);
void getStudentInfo();
};
Main.cpp
#include<iostream>
#include "Student.h"
#include "Status.h"
using namespace std;
Student::Student():studentId(0),firstName(""),lastName("") {}
Student::Student(int a,string b,string c):
studentId(a),firstName(b),lastName(c) {}
void Student :: getStudentInfo(){
cout<<"First Name: "<<firstName<<" \nLast Name: "<<lastName
<<" Status: "<<studentStatus<<endl;
}
int main(){
int sid;
string fn,ln;
cout<<"Enter Student ID:"<<endl;
cin>>sid;
cout<<"Enter first name:"<<endl;
cin>>fn;
cout<<"Enter last name:"<<endl;
cin>>ln;
Student obj(sid,fn,ln);
cout<<"Is the student present type y/n"<<endl;
char ans;
cin>>ans;
if(ans=='y'){
obj.studentStatus=Attending;
}
else if(ans=='n'){
cout<<"Is a degree obtained? y/n"<<endl;
char ans2;
cin>>ans2;
if(ans2=='y'){
obj.studentStatus=Graduated;
}
else if(ans2=='n'){
obj.studentStatus=nonAttending;
}
}
obj.getStudentInfo();
return 0;
}
if you need any further help, you can comment
Attaching screenshot of working code