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;
   }
}

It looks like you're on the right track. Do you have a specific question?

Well, String is not string. You have to write it in lowercase.

void toString();

should be:

void toString(string &target);

void Employee::toString(string &target){
target = "Name: " + empName + " / Employee Number: " + empNum + " / Hire Date: " + hireDate;
}

My code above (the completed code) is in java... my questiion would be can some one tell me what to do next or if yu have a conversion into C++ cod can i see it. I'm trying to learn on my own and need a little demo to look at.

It looks like you're on the right track. Do you have a specific question?

My code above (the completed code) is in java... my questiion would be can some one tell me what to do next or if yu have a conversion into C++ cod can i see it. I'm trying to learn on my own and need a little demo to look at.

>my questiion would be
Ooh, let's see.

>can some one tell me what to do next
That's not a question, that's a request for hand holding. By specific question, I mean specific question. Not "I'm clueless, tell me what to do!".

>if yu have a conversion into C++ cod can i see it
That's not a question either, it's a request for us to do your research for you. As you may have guessed by now, that's not how it works.

>I'm trying to learn on my own and need a little demo to look at.
No, you need to learn enough about Java to understand the code you're trying to convert. Then you need to learn enough about C++ to understand how to write code that does the same thing as the code you're trying to convert. C++ and Java are similar enough, especially with this trivial program, that I'm not going to cut you any slack. Common sense will take even the greenest of beginners through most of the exercise.

i want to learn how to convert a java program into c++

learn both languages then you will most likely know how to do it.

You should use the namespace:: such as std::string so your code is more portable and more clear.

using namespace std; is not a good thing to do, it can cuse clashes, such as if you write your own string library because you need something.

portable means you can port the code from one language to another, or porting from one platform to another (!). the code is also more compatible with a job.

You should also know about C++ that you can do dot addressing just like JavaScript:
if (std::string("1st").substr((std::string("1st").size()-1)-2,std::string("1st").size()-2).find("st")!=std::string::npos) //take the last 2 characters from the string

Just lettin' ya know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.