Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Part 1: Create the Student class 1. Create a class called Student. It should hav

ID: 3728365 • Letter: P

Question

Part 1: Create the Student class 1. Create a class called Student. It should have the following instance variables: Name of Instance variable Description of instance variable Student's first and last name name major numCreditsPassedTotal number of credit hours completed by the student (such as 72) Major of student (such as “IT”, “Math", "Undecided" Make this an integer data t Make this an integer data t numCreditsCurrentTotal number of credit hours the student is enrolled in this semester. 2. Create a constructor for Student which does not have any parameters. Inside the constructor, initialize all the instance variables using your personal information. Create a constructor for Student which has 4 parameters. Use the parameter variables to set the instance variables. 3. 4. Create the getters and setters for all of the instance variales 5. Create the printData method that will SOP each of the instance variables 6. Create an instance method called isUpperclassmen. There are no parameters to this method. It returns true if number of credits passed is 60 or above. Otherwise, it returns false Create an instance method called calculateRemainingHours. There are no parameters to this method. It returns the number of hours the student must complete to earn a degree. Assume that all degrees require 123 credit hours for completion. So, remaining hours = 123-numCreditsPassed 7. 8. Create an instance method called calulateBill, There are no parameters to this method. It returns the cost for student attending classes for the current semester. This is calculated as shown in the following table Number of credit hours 0 to 6 Calculation of Bill $100.25 for each credit hour you are currently enrolled $100.25 for each credit hour you are currently enrolled PLUS a fee of $500 > 6

Explanation / Answer

/*
* Student.h
*
* Created on: 12-Mar-2018
*      Author: tan
*/
#include <string>

using namespace std;
#ifndef STUDENT_H_
#define STUDENT_H_

class Student {
   string name;
   string major;
   int numCreditPassed;
   int numCreditCurrent;
public:
   Student();
   Student(string,string,int,int);
   void setName(string);
   void setMajor(string);
   void setCreditPassed(int);
   void setCreditCurrent(int);
   string getName();
   string getMajor();
   int getCreditPassed();
   int getCreditCurrent();
   void printData();
   bool isUpperclassmen();
   int calculateRemainingHours();
   double calculateBill();
};

#endif /* STUDENT_H_ */


/*******************/

/*
* Student.cpp
*
* Created on: 12-Mar-2018
*      Author: tan
*/

#include "Student.h"
#include <iostream>
Student::Student() {
   // TODO Auto-generated constructor stub
   name="John";
   major="IT";
   numCreditPassed=0;
   numCreditCurrent=0;
}
Student::Student(string nm,string maj,int pass,int curr){
   name=nm;
   major=maj;
   numCreditPassed=pass;
   numCreditCurrent=curr;
}
void Student::setName(string nm){
   name=nm;
}
void Student::setMajor(string maj){
   major=maj;
}
void Student::setCreditPassed(int pass){
   numCreditPassed=pass;
}
void Student::setCreditCurrent(int curr){
   numCreditCurrent=curr;
}
string Student::getName(){
   return name;
}
string Student::getMajor(){
   return major;
}
int Student::getCreditPassed(){
   return numCreditPassed;
}
int Student::getCreditCurrent(){
   return numCreditCurrent;
}
void Student::printData(){
   cout<<"Printing Student information"<<endl;
   cout<<"Name: "<<name<<endl;
   cout<<"Major: "<<major<<endl;
   cout<<"Credit Passed: "<<numCreditPassed<<endl;
   cout<<"Credit Current: "<<numCreditCurrent<<endl;
}
bool Student::isUpperclassmen(){
   return numCreditPassed>=60;
}
int Student::calculateRemainingHours(){
   return 123-numCreditPassed;
}
double Student::calculateBill(){
   if(numCreditCurrent<=6){
       return numCreditCurrent*100.25;
   }
   else{
       return numCreditCurrent*100.25+500;
   }
}


/*********************/

/*
* StudentTester.h
*
* Created on: 12-Mar-2018
*      Author: tan
*/
#include <string>
using namespace std;
#ifndef STUDENTTESTER_H_
#define STUDENTTESTER_H_

class StudentTester {
public:
   StudentTester();
   friend int main();
};

#endif /* STUDENTTESTER_H_ */


/*****************/

/*
* StudentTester.cpp
*
* Created on: 12-Mar-2018
*      Author: tan
*/
#include <iostream>
#include "StudentTester.h"
#include "Student.h"
StudentTester::StudentTester() {
   // TODO Auto-generated constructor stub

}
int main(){
   string name;
   string major;
   int numCreditPassed;
   int numCreditCurrent;
   cout<<"Enter the student name: ";
   cin>>name;
   cout<<"Enter the student Major: ";
   cin>>major;
   cout<<"Enter the credit hour passed: ";
   cin>>numCreditPassed;
   if(numCreditPassed<0){
       numCreditPassed=0;
       cout<<"Credit hour cannot be negative"<<endl;
   }
   cout<<"Enter the credit hour current: ";
   cin>>numCreditCurrent;
   if(numCreditCurrent<0){
       numCreditCurrent=0;
       cout<<"Credit hour cannot be negative"<<endl;
   }
   Student student1(name,major,numCreditPassed,numCreditCurrent);
   student1.printData();
   cout<<"Upper Class: "<<student1.isUpperclassmen()<<endl;
   cout<<"Remaining hours: "<<student1.calculateRemainingHours()<<endl;
   cout<<"Bill: "<<student1.calculateBill()<<endl;
   return 0;
}


/*******************/output

Enter the credit hour passed: 78
Enter the credit hour current: 4
Printing Student information
Name: Jack
Major: CSE
Credit Passed: 78
Credit Current: 4
Upper Class: 1
Remaining hours: 45
Bill: 401