Question

In: Computer Science

In this Pluralsight Lab, you will continue viewing the course C++ Fundamentals Including C++ 17 by...

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:

  • Module 5 (Language Basics - User Defined Types)
  • Module 6 (Language Basics - Flow of Control)

Then complete the following tasks:

  • Use the Class Wizard in Visual Studio to create a class called Student. (Note that the Class Wizard will automatically create the .h and .cpp files.)
  • Your Student class should have the following class members/properties: studentID, firstName, lastName, and studentStatus. (Note that the studentStatus member will be of type Status, which is an enum you will create.)
  • Create a default and constructor and a constructor that requires only the Student Id, first name, and last name. (The studentStatus member should not be initialized at this time.)
  • Create a member function called getStudentInfo() that returns a string that contains the students first name, last name, and their status.
  • Create a destructor for the Student class. (Note that the Class Wizard automatically includes a destructor.)
  • Add a status.h file to the solution. Then add a Status enumeration to that file with the following entries: Attending, NonAttending, and Graduated. Then include this file in your class file.
  • Add #pragma once to all of your header files
  • Write a simple program that asks the user for the Student Id, first name, and last name of the student. Then instantiates a new student object with this information.
  • Ask the user if the student is presently attending the school. If the user states "no", ask if a degree was obtain. Use the ternary operator to set studentStatus member of the object to either NonAttending or Graduated based on whether a degree was obtained.
  • If the user states that the student is attending, set the studentStatus to Attending.
  • Display the student's information by calling the getStudentInfo() member function.

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

Solutions

Expert Solution

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


Related Solutions

explain industry analysis fundamentals including boundaries and competition?
explain industry analysis fundamentals including boundaries and competition?
For this lab you will continue your dynamic array by completing the class called MyDynamicArray. The...
For this lab you will continue your dynamic array by completing the class called MyDynamicArray. The MyDynamicArray class should manage the storage of an array that can grow and shrink. The public methods of your class should already be the following: MyDynamicArray(); Default Constructor. The array should be of capacity 2. MyDynamicArray(int s); For this constructor the array should be of capacity and size s. int& operator[](int i); Traditional [] operator. Should print a message if i is out of...
In this final entry into your Nurse E-Portfolio for this course, you continue to have opportunities...
In this final entry into your Nurse E-Portfolio for this course, you continue to have opportunities for reflective practice. In this entry you expand your understanding and knowledge of nutrition. Using the e-portfolio format, answer the following questions. Make sure you spend some time thinking about the answers to these questions before writing. Since your mid-course entry have you made any changes in your 1-5 rating where 5 represents the most "healthy eater." What number would you give yourself now?...
In my lab, we conducted an experiment to demonstrate both Hess' Law and the fundamentals of...
In my lab, we conducted an experiment to demonstrate both Hess' Law and the fundamentals of enthalpy via the formation of magnesium oxide. In this experiment, 2 specific sub-reactions were conducted: 1. MgO(s) + 2HCl(aq) > MgCl2(aq) + H2O(l) 2. Mg(s) + 2HCl(aq) > MgCl2(aq) + H2(g) In these two reactions, different concentrations of HCl were used: the first reaction called for 100mL of 6M HCl, while the second reaction called for 120mL of 6M HCl. The lab manual says...
***This is a International Finance course*** Summarize the fundamentals equilibrium path. In your own words, propose...
***This is a International Finance course*** Summarize the fundamentals equilibrium path. In your own words, propose its significance.
After viewing the supplemental video "Strategic Management: Strategy Evaluation and Control" in the course content, describe...
After viewing the supplemental video "Strategic Management: Strategy Evaluation and Control" in the course content, describe why the Balanced Scorecard method may or may not be useful in the monitoring and evaluation process
David, an undergraduate intern in our lab, forget to block the blot with BSA and continue...
David, an undergraduate intern in our lab, forget to block the blot with BSA and continue to the antibody hybridization steps and finally developed his blot. Could you please describe his blot picture without even looking!
What does break and continue mean in C++?
What does break and continue mean in C++?
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT