I NEED ALL QUESTIONS OR ELSE THUMBS DOWN!
C++
Implement a structure Employee. An employee has a name (a char
*) and a salary (a double). Write a default constructor, a
constructor with two parameters (name and salary), and methods
char* getName()
double getSalary() to return the name and salary.
Write a small global function TestEmployee() to test your
structure.
Creating a new employee.
Please type the name:
Larry Bird
Please specify the salary: 200000
New employee has been created.
Name of employee: Larry Bird
Salary: 200000.0
Thank you for testing structure Employee.
Question 2:
Implement a structure Car with the following properties. A car has
a certain fuel efficiency (measured in miles per gallon or liters
per km pick one) of type float and a certain amount of fuel in the
gas tank of type float. The efficiency is specified in the
constructor, and the initial fuel level is 0. Supply a method drive
(float) that simulates driving the car for a certain distance,
reducing the fuel level in the gas tank, and methods
float getFuelLevel() returning the current fuel level, and
void tank(float), to tank up.
Sample usage of the structure:
void main() {
Car myBeemer(29);
cout<<myBeemer.getFuelLevel()<<endl;
myBeemer.tank(20);
cout<<myBeemer.getFuelLevel()<<endl;
myBeemer.drive(100);
cout<< myBeemer.getFuelLevel()<<endl;
}
Should produce:
0.0
20.0
16.551724137931036
Question 3:
Implement a structure Circle (think of its data members) that has
methods
float getArea() and
float getCircumference()
In the constructor, supply the radius of the circle.
Please specify the radius of your circle: 1.0
Circle created.
Area: 3.141592653589793
Circumference: 6.283185307179586
Good-bye!
Question 4:
Define a structure FlightInfo in C++ with following
description:
Private Members A data member FlightNumber of type integer A data
member Destination of type char* A data member Distance of type
float A data member Fuel of type float
A member function void calFuel() to calculate the value of Fuel as
per the following criteria and set its corresponding data member
Distance Fuel <=1000 500 more than 1000 and <=2000 1100 more
than 2000 2200
Public Members A function void feedInfo() to allow user to enter
values for Flight Number, Destination, Distance & call function
void calFuel() to calculate the quantity of Fuel A function void
showInfo() to allow user to view the content of all the data
members
A function float getFuel() that returns the current fuel
value.
Question 5:
Implement a structure Employee2. An employee has a name (a char *)
, HourlyWage (float) , WorkedHours(float) and
ExtraHours(float).
Write a function
float wageCalculator()
that reads in the name and hourly wage of an employee. Then ask how
many hours the employee worked in the past week. Be sure to accept
fractional hours. Compute the pay. Any overtime work (over 40 hours
per week) is paid at 150 percent of the regular wage. Print a
paycheck for the employee.
Please enter employee's name then press Enter : Larry Bird
Please enter hourly wage then press Enter : 12.50
Please enter hours worked then press Enter: 10
Paycheck for employee Larry Bird
Hours worked: 10.0
Hourly wage: 12.5
Total payment: 125.0
Please enter employee's name then press Enter : Michael
Jordan
Please enter hourly wage then press Enter : 10
Please enter hours worked then press Enter: 50
Paycheck for employee Michael Jordan
Hours worked: 50.0
Hourly wage: 10.0
Overtime hours: 10.0
Overtime hourly wage: 15.0
Total payment: 550.0
Comment down for any
queries
Please give a thumbs up if you are satisfied with the
answer
All Answers are below!
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
struct Employee
{
private:
char *name;
double salary;
public:
Employee()
{
name=new
char[100];
salary=0;
}
Employee(char *n,double s)
{
if(s>0)
{
salary=s;
name=n;
}
}
char* getName()
{
return
name;
}
double getSalary()
{
return
salary;
}
};
void TestEmployee()
{
char *n=new char[100];
double s;
cout<<"Please type the name"<<endl;
cin>>n;
cout<<"Please specify the
salary"<<endl;
cin>>s;
Employee test(n,s);
cout<<"Name of
employee:"<<test.getName()<<endl;
cout<<"salary:"<<test.getSalary()<<endl;
cout<<"Thankyou for testing structure Employee."<<endl;
}
int main()
{
TestEmployee();
}
//Q2
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
struct Car
{
private:
float milage;
float currentfuel;
public:
Car()
{
milage=18;
currentfuel=0;
}
Car(float m)
{
if(m>0)
{
milage=m;
currentfuel=0;
}
}
float getFuelLevel()
{
return
currentfuel;
}
void tank(float liters)
{
currentfuel+=liters;
}
void drive(float distance)
{
currentfuel=currentfuel -(distance/milage);
}
};
int main()
{
Car myBeemer(29);
cout<<myBeemer.getFuelLevel()<<endl;
myBeemer.tank(20);
cout<<myBeemer.getFuelLevel()<<endl;
myBeemer.drive(100);
cout<<
myBeemer.getFuelLevel()<<endl;
}
//Q3
#include<iostream>
#include<string>
using namespace std;
struct Circle
{
private:
float radius;
float area;
float circumference;
public:
Circle()
{
radius=1;
}
Circle(double r)
{
radius=r;
}
float getArea()
{
area=3.14*radius*radius;
return
area;
}
float getCircumference()
{
circumference=2*3.14*radius;
return
circumference;
}
};
int main()
{
Circle myBeemer(3);
cout<<myBeemer.getArea()<<endl;
myBeemer.getArea();
cout<<myBeemer.getArea()<<endl;
myBeemer.getCircumference();
cout<<
myBeemer.getCircumference()<<endl;
}
//Q4
#include<iostream>
#include<string>
using namespace std;
struct FlightInfo
{
private:
int FlightNumber;
char *Destination;
float Distance;
float Fuel;
void calFuel(float Distance)
{
if
(Distance>0)
{
if (Distance<=1000)
{
Fuel=500;
}
else if (Distance>1000 &&
Distance<=2000)
{
Fuel=1100;
}
else
{
Fuel=2200;
}
}
}
public:
void feedInfo()
{
cout<<"Please enter your Flight Number ";
cin>>this->FlightNumber;
this->Destination=new char [50];
cout<<"Please enter your Destination = ";
cin.ignore();
cin.getline(this->Destination,50);
cout<<"Please enter the Distance = ";
cin>>this->Distance;
calFuel(Distance);
}
void showInfo()
{
cout<<"Flight Number :
"<<this->FlightNumber<<endl;
cout<<"Destination :
"<<this->Destination<<endl;
cout<<"Distance :
"<<this->Distance<<endl;
cout<<"Fuel = "<<this->Fuel<<endl;
}
float getFuel()
{
return
this->Fuel;
}
};
int main()
{
FlightInfo obj1;
obj1.feedInfo();
obj1.showInfo();
}
//Q5
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
struct Employee2
{
private:
char *name;
float HourlyWage;
float WorkedHours;
float ExtraHours;
public:
float wageCalculator()
{
float
Totalpayment;
float
ExtraWage;
this->name=new char[50];
cout<<"Please enter the name of employe:
"<<endl;;
//cin.ignore();
cin.getline(this->name,50);
cout<<"Please enter HourlyWage of
employee:"<<endl;
cin>>this->HourlyWage;
cout<<"Please enter Hours worked by emplyee:
"<<endl;
cin>>this->WorkedHours;
cout<<"Pay Check for emplyee: "<<this->name<<endl;
if(this->WorkedHours>40)
{
this->ExtraHours=this->WorkedHours-40;
cout<<"Hours
Worked:"<<this->WorkedHours<<endl;
cout<<"Hourly
Wage:"<<this->HourlyWage<<endl;
cout<<"Extra
Hours:"<<this->ExtraHours<<endl;
ExtraWage=(150.0/100)*HourlyWage;
cout<<"Over time Hourly
Wage:"<<ExtraWage<<endl<<endl;
Totalpayment=(this->HourlyWage*40)+(ExtraWage
* ExtraHours);
cout<<"Total Payment:
"<<Totalpayment;
}
else
{
cout<<"Hours
Worked:"<<this->WorkedHours<<endl;
cout<<"Hourly
Wage:"<<this->HourlyWage<<endl;
Totalpayment=(this->HourlyWage*this->WorkedHours);
cout<<"Total Payment:
"<<Totalpayment;
}
}
};
int main()
{
Employee2 p;
p.wageCalculator();
}
I NEED ALL QUESTIONS OR ELSE THUMBS DOWN! C++ Implement a structure Employee. An employee has...
If the employee is a supervisor calculate her paycheck as her yearly salary / 52 (weekly pay) If the employee is not a supervisor and she worked 40 hours or less calculate her paycheck as her hourly wage * hours worked (regular pay) If the employee is not a supervisor and worked more than 40 hours calculate her paycheck as her (hourly wage * 40 ) + (1 ½ times here hourly wage * her hours worked over 40) (overtime...
in c++ Define and implement the class Employee with the following requirements: private data members string type name a. b. double type hourlyRate 2. public member functions a. default constructor that sets the data member name to blank"and hourlyRate to zero b. A constructor with parameters to initialize the private data members c. Set and get methods for all private data members d. A constant method weeklyPay() that receives a parameter representing the number of hours the employee worked per...
Java Problem 2: Employee (10 points) (Software Design) Create an abstract class that represents an Employee and contains abstract method payment. Create concrete classes: SalaryEmployee, CommissionEmployee, HourlyEmployee which extend the Employee class and implements that abstract method. A Salary Employee has a salary, a Commision Employee has a commission rate and total sales, and Hourly Employee as an hourly rate and hours worked Software Architecture: The Employee class is the abstract super class and must be instantiated by one of...
// I am going to use if and else stamtents for this employee pay clalulations. //using if and else to cal salary //If hours worked is <= 40.0 //Employee salry will = hours*pay rate //else //employess salary will =40*pay rate +(hours worked-40)*1.5* pay rate. #include using namespace std; const double Max_Hours= 40.0; const double MuLTIPLER = 1.5; char salary; char payrate; char hours_worked; char Max_hours; char get_total_pay; int main() { double Hours=0; double Payrate = 0; cout <<"Please enter employee...
Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment. You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...
J Inc. has a file with employee details. You are asked to write a C++ program to read the file and display the results with appropriate formatting. Read from the file a person's name, SSN, and hourly wage, the number of hours worked in a week, and his or her status and store it in appropriate vector of obiects. For the output, you must display the person's name, SSN, wage, hours worked, straight time pay, overtime pay, employee status and...
c++ please need help with this question Consider a class Employee with data members: age(an integer), id (an integer) and salary (a float), and their corresponding member functions as follows: class Employee { private: int age; int id; float salary; public: Employee( ); // default constructor: age=0, id=0, and salary=0 Employee(Employee &x); // copy constructor Employee& operator = (Employee &x); // equal sign operator void setAge(int x); // let age = x...
C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...
Visual C# C# Visual Studio 2017 You are to create a class object called “Employee” which included eight private variables - firstN - lastN - idNum -wage: holds how much the person makes per hour -weekHrsWkd: holds how many total hours the person worked each week. - regHrsAmt: initialize to a fixed amount of 40 using constructor. - regPay - otPay After going over the regular hours, the employee gets 1.5x the wage for each additional hour worked. Methods: -...
employee.h ---------- #include <stdio.h> #include <iostream> #include <fstream> class Employee { private: int employeeNum; std::string name; std::string address; std::string phoneNum; double hrWage, hrWorked; public: Employee(int en, std::string n, std::string a, std::string pn, double hw, double hwo); std::string getName(); void setName(std::string n); int getENum(); std::string getAdd(); void setAdd(std::string a); std::string getPhone(); void setPhone(std::string p); double getWage(); void setWage(double w); double getHours(); void setHours(double h); double calcPay(double a, double b); static Employee read(std::ifstream& in); void write(std::ofstream& out); }; employee.cpp ---------- //employee.cpp #include...