I have a program that i need to convert from java to c++... i just need help doing it... heres the java:
/*
Name: Joseph Coleman
Class:CSCI 1302
Assignment: Employee + ProductionWorker
Academic Honesty:
The integrity of students and their written and oral work is a critical component of
the academic process. The submission of another?s work as one's own is plagiarism.
Students shall be guilty of violating the honor code if they:
1. Represent the work of others as their own.
2. Use or obtain unauthorized assistance in any academic work.
3. Give unauthorized assistance to other students.
4. Modify, without instructor approval, an examination, paper,
record, or report for the purpose of obtaining additional credit.
5. Misrepresent the content of submitted work.
The penalty for violating the honor code is severe. Any student violating the
honor code is subject to receive a failing grade for the course and will be reported
to the Office of Student Affairs. If a student is unclear about whether a particular
situation may constitute an honor code violation, the student should meet with the
instructor to discuss the situation.
*/
public class Employee1
{
private String empName;
private String empNum;
private String hireDate;
public Employee(String na, String nu, String hd)
{
empName = na;
empNum = nu;
hireDate = hd;
}
public String toString()
{
String str;
str = "Name: " + empName + " / Employee Number: " + empNum + " / Hire Date: " + hireDate;
return str;
}
}
class ProductionWorker extends Employee
{
private int shift;
private double hourlyPay;
public ProductionWorker(String na, String nu, String hd)
{
super(na, nu, hd);
}
public void setShift(int s)
{
shift = s;
}
public String getShift()
{
String str2;
if (shift == 1)
str2 = "Day";
else if (shift == 2)
str2 = "Night";
else
str2 = "Invalid Shift.";
return str2;
}
public void setHourlyPay(double hPay)
{
hourlyPay = hPay;
}
public double getHourlyPay()
{
return hourlyPay;
}
}
class EmployeeDemo
{
public static void main(String[]args)
{
ProductionWorker prodWorker = new ProductionWorker("John Johnson" , "252-A", "09/21/2001");
prodWorker.setShift(2);
prodWorker.setHourlyPay(23.50);
prodWorker.toString();
System.out.println(prodWorker);
System.out.println("Shift: " + prodWorker.getShift());
System.out.println("Hourly Pay Rate: " + prodWorker.getHourlyPay());
}
}
/*
Sample Output:
Name: John Johnson
Employee Number: 252-A /
Hire Date: 09/21/2001
Shift: Day
Hourly Pay Rate: 23.50
*/
and here is what my C++ looks like (its short idk if i'm doing it right):
#include <cstdlib>
#include <iostream>
#include <string>
/*
name:Joseph COleman
Class: CSCI 2350
Date: 11/17/09
Purpose: - Use clasess for problem solving
- Convert Integers to Strings
*/
using namespace std;
class Employee
{
private:
String empName;
String empNum;
String hireDate;
public:
Employee(String, String, String);
void toString();
};
Employee::Employee(String na, String nu, String hd)
{
empName = na;
empNum = nu;
hireDate = hd;
}
}