1. Please answer the questions below.

a. A header (.h file) has the class in it. A cpp file has the implementation of said header a.k.a class. Tell me what is the difference between a class (the header file) and an object that uses that said class?

b. Name a 3 differences in regards to SYNTAX in C++ compared to Java or C++?

c. Why are functions useful?

d. Why not make all variables global?

e. Look up Big Oh notation and give a coding example that is of 0(n^2). What does 0(n^2) mean? Please reference where you got the information and example (paste the link, name of book)

2. Please explain what each line does in this program, using comments syntax.

#include

using namespace std;

class CourseMaterial {
private:
double total_points;
double cumulative_points;
int material_number;

public:
CourseMaterial();
CourseMaterial(double tps, int mn);
bool set_total_points(double tps);
double get_total_points();

bool add_cumulative_points(double mp);
double get_cumulative_points();
bool set_material_number(int mn);
int get_material_number();
double return_final_score();
};

CourseMaterial::CourseMaterial() {
total_points=0.0;
cumulative_points=0.0;
material_number = -1;
}

CourseMaterial::CourseMaterial(double tps, int mn) {
if (tps <= 0) {
cout << "Total Points for course should be greater than zero"< total_points = 0.0;
} else {
total_points = tps;
}

if(mn < 0){
cout << "Material Number should be greater than zero"< material_number = -1;
} else {
material_number = mn;
}
}

bool CourseMaterial::set_total_points(double tps){
if (tps <= 0){
cout << "Total Points for course should be greater than zero"<
return false;
}

total_points = tps;

return true;

}

double CourseMaterial::get_total_points(){
return total_points;
}

bool CourseMaterial::add_cumulative_points(double mp){
if (mp >= 0){
cumulative_points += mp;

return true;
}

cout << "Points to be added cannot be less than zero"< return false;
}

double CourseMaterial::get_cumulative_points(){
Return the value of the cumulative points
return cumulative_points;
}

bool CourseMaterial::set_material_number(int mn){
if (mn < 0){
cout << "Can't set Material Number to be less than zero"<
return false;
}

material_number = mn;

return true;
}

int CourseMaterial::get_material_number(){
return material_number;
}

double CourseMaterial::return_final_score(){
if(total_points <= 0){
cout <<"Can not return final score for course material since total_points has not been set"<
return -1.0;
}

return (cumulative_points/total_points)*100;
}

3. Look over the Employee.h class file. Implement that class in a file called Employee.cpp. Create an Employee object for each constructor and call writec onsole function after each object in a file called main.cpp

See Employee.cpp, Employee.h, and main.cpp file for source code.

//
// Employee.h
// Homework1
//
// Created by Maria Saenz on 5/28/16.
// Copyright © 2016 Maria Saenz. All rights reserved.
//

#ifndef Employee_h
#define Employee_h
class Employee {
private:
int eid; //employee id number
int dob; //date of birth, example 431985
double salary; //salary for user 135000
char status; //E for employed, R for retired, T for terminated

public:
//constructors
Employee(); //default constructor set all variables to default values, i.e. NULL or 0, or E for status
Employee(int eidentifier, int dateofbirth, double sal, char stat);
Employee (int eidentifier, double sal, char stat);
//accessors
int get_eid();
int get_dob();
double get_salary();
char get_status();
//member functions
void write_console(); //writes out the information of th user

};
#endif /* Employee_h */
//
// Employee.cpp
// Homework1
//
// Created by Maria Saenz on 5/28/16.
// Copyright © 2016 Maria Saenz. All rights reserved.
//

#include < iostream>
#include "Employee.h"

using namespace std;

/** Implements all 3 constructors and functions that are in the class header file **/

//constructors
Employee::Employee()
{
//default constructor set all variables to default values, i.e. NULL or 0, or E for status
eid = 0;
dob = 0;
salary = 0;
status = 'E';
}

Employee::Employee(int eidentifier, int dateofbirth, double sal, char stat)
{
eid = eidentifier;
dob = dateofbirth;
salary = sal;
status = stat;
}

Employee::Employee(int eidentifier, double sal, char stat)
{
eid = eidentifier;
dob = 0;
salary = sal;
status = stat;
}

//accessors
int Employee::get_eid()
{
return eid;
}

int Employee::get_dob()
{
return dob;
}

double Employee::get_salary()
{
return salary;
}

char Employee::get_status()
{
return status;
}

//member functions
void Employee::write_console()
{
//writes out the information of th user
if (eid == 0 || dob == 0 || salary == 0)
{
cout << "Not all attributes are filled out for Employee" << endl;
}
else
{
cout << "Employee ID: " << eid << endl;
cout << "Date of Birth: " << dob << endl;
cout << "Salary: $" << salary << endl;
cout << "Status: " << status << endl;
}
}

/**
* Use the Excercise that we did in class with the Rectangle. Make sure to check that the input is correct constructor,
* like the Rectagle example. The writeconsole function literally will do a cout (print) of all the variables that are part of Employee,
* example output is: EmployeeID: 1234857 DateOfBirth:431985 Salary:220000 Status:E, if ANY of the variables are defaulted print a
* statement saying: Not all attributes are filled out for Employee
*/
//
// main.cpp
// Homework1
//
// Created by Maria Saenz on 5/28/16.
// Copyright © 2016 Maria Saenz. All rights reserved.
//

#include < iostream>
#include "Employee.h"

using namespace std;

int main(int argc, const char * argv[]) {
//Create an employee object for each constructor, and call print writeconsole for each one

return 0;
}
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.