Results 1 to 8 of 8

Thread: convert C++ program in Java code

  1. #1
    Join Date
    Jul 2010
    Posts
    3

    sad convert C++ program in Java code

    Hello All,

    Please help me to convert C++ program in Java code...
    I am putting C++ code below

    #include<iostream.h>
    #include<conio.h>
    #define MaxStack 10
    #define MaxMaze 5

    class Stack{
    private:
    int item[MaxStack];
    int mytop;
    public:
    Stack(){
    mytop=-1;
    }
    int IsEmpty(){
    return (mytop==-1);
    }
    void push(int val){
    if(mytop==MaxStack-1){
    cout << "Stack Is Full.";
    return;
    }
    item[++mytop]=val;
    }
    int pop(){
    if(IsEmpty()){
    cout << "Stack Is Empty.";
    return -1;
    }
    return item[mytop--];
    }
    };

    void main(){
    char a[MaxMaze][MaxMaze]={
    {' ',' ','*','*','*'},
    {'*',' ','*',' ',' '},
    {'*',' ','*',' ','*'},
    {'*',' ',' ',' ','*'},
    {'*','*','*','*','*'}
    };
    Stack s1,s2;
    int i=0,j=0;
    clrscr();

    while(j>=0 && i>=0)
    {
    while(i>=0 && a[i][j]!='*' && a[i][j]!='-')
    {
    while(j<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    {
    while(i<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    {
    a[i][j]='-';
    s1.push(i);
    i++;
    }
    i=s1.pop();
    s2.push(j);
    j++;
    }
    j=s2.pop();
    s1.push(i);
    i--;
    }
    i=s1.pop();
    s2.push(j);
    j--;
    }
    for(i=0;i<MaxMaze;i++)
    {
    for(j=0;j<MaxMaze;j++)
    cout<< a[i][j] << " ";
    cout << endl;
    }
    getch();
    }


    Please anyone convert this C++ program into Java as soon as possible.

    Thanks in advance
    Vaibhav

  2. #2
    Join Date
    Nov 2009
    Posts
    583

    Re: convert C++ program in Java code

    Please check your converted code to java

    Code:
    class Stack
    {
    public static int MaxStack = 10;
    public static int MaxMaze = 5;
    
    int item [MaxStack];
    int my top;
    
    public Stack()
    {
    mytop =- 1;
    }
    
    public int IsEmpty()
    {
    return (mytop == -1);
    }
    
    public void push(int val)
    {
    if (mytop == MaxStack - 1)
    {
    System.out.println("Stack Is Full");
    return ;
    }
    item[++mytop] = val;
    }
    
    public pop()
    {
    if(IsEmpty())
    {
    System.out.println("Stack Is Empty");
    }
    return -1;
    }
    return item[mytop--];
    }
    
    public static void main (String args[])
    {
    
    char a[MaxMaze][MaxMaze] = {
    {' ',' ','*','*','*'},
    {'*',' ','*',' ',' '},
    {'*',' ','*',' ','*'},
    {'*',' ',' ',' ','*'},
    {'*','*','*','*','*'}
    };
    
    Stack s1 = new Stack();
    Stack s1 = new Stack();
    
    int i = 0 , j = 0;
    
    while(j>=0 && i>=0)
    {
    while(i>=0 && a[i][j]!='*' && a[i][j]!='-')
    {
    while(j<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    {
    while(i<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    {
    a[i][j]='-';
    s1.push(i);
    i++;
    }
    i=s1.pop();
    s2.push(j);
    j++;
    }
    j=s2.pop();
    s1.push(i);
    i--;
    }
    i=s1.pop();
    s2.push(j);
    j--;
    }
    for(i=0;i<MaxMaze;i++)
    {
    for(j=0;j<MaxMaze;j++)
    System.out.println(a[i][j]);
    System.out.println();
    }
    
    }
    If any problem post back

  3. #3
    Join Date
    Jul 2010
    Posts
    3

    Re: convert C++ program in Java code

    Thanks bro for your help...
    but the thing is that this program is giving 32 error while compiling program...
    please make it check....

    Thanks,
    VaibhaV

  4. #4
    Join Date
    Dec 2007
    Posts
    2,291

    Re: convert C++ program in Java code

    There are tons of software available to Convert C++ to Java code if you can search on google. Download C++ to Java Converter that can save you countless hours of painstaking work. The Java code produced is closer to functional production-quality code than the code produced by any other C++ to Java converter on the market today.

  5. #5
    Join Date
    Jul 2010
    Posts
    3

    Re: convert C++ program in Java code

    Quote Originally Posted by einstein_007 View Post
    There are tons of software available to Convert C++ to Java code if you can search on google. Download C++ to Java Converter that can save you countless hours of painstaking work. The Java code produced is closer to functional production-quality code than the code produced by any other C++ to Java converter on the market today.

    bro, i already did googling to search out a software for me but wasnt able to get it... so plz if u know any software then let me know... thnx

  6. #6
    Join Date
    May 2008
    Posts
    2,297

    Re: convert C++ program in Java code

    Get installation of C2J software download. This will surely let you to get the thing to make it work well and function. So do check and make the changes to be worked. This will surely let you to get to a proper ailment and solution. So do check and process as needed. It will be helpful.

  7. #7
    Join Date
    Nov 2009
    Posts
    583

    Re: convert C++ program in Java code

    Please check the code now

    Code:
    public class Stack
    {
    	public static final int MaxStack = 5;
    	public static final int MaxMaze = 5;
    	int item[] = new int[MaxStack];
    	int mytop;
    	
    	public Stack()
    	{
    		mytop =- 1;
    	}
    	
    	public boolean IsEmpty()
    	{
    		return (mytop == -1);
    	}
    	
    	public void push(int val)
    	{
    		if (mytop == MaxStack - 1)
    		{
    			System.out.println("Stack Is Full");
    			return ;
    		}
    	item[++mytop] = val;
    	}
    	
    	public int pop()
    	{
    		if(IsEmpty())
    		{
    			System.out.println("Stack Is Empty");
    			return -1;
    		}
    		return item[mytop--];
    	}
    	
    	public static void main (String args[])
    	{
    		char[][] a = new char[MaxMaze][MaxMaze] = {
    				{' ',' ','*','*','*'},
    				{'*',' ','*',' ',' '},
    				{'*',' ','*',' ','*'},
    				{'*',' ',' ',' ','*'},
    				{'*','*','*','*','*'}
    				};
    		
    		Stack s1 = new Stack();
    		Stack s2 = new Stack();
    
    		int i = 0 , j = 0;
    		
    		while(j>=0 && i>=0)
    		{
    			while(i>=0 && a[i][j]!='*' && a[i][j]!='-')
    			{
    				while(j<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    				{
    					while(i<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    					{
    						a[i][j]='-';
    						s1.push(i);
    						i++;
    					}
    					i=s1.pop();
    					s2.push(j);
    					j++;
    				}
    				j=s2.pop();
    				s1.push(i);
    				i--;
    			}
    			i=s1.pop();
    			s2.push(j);
    			j--;
    		}
    		
    		for(i=0;i<MaxMaze;i++)
    		{
    			for(j=0;j<MaxMaze;j++)
    			{
    				System.out.println(a[i][j]);
    				System.out.println();
    			}
    		}
    	}
    }

  8. #8
    Join Date
    Nov 2009
    Posts
    583

    Re: convert C++ program in Java code

    I have checked this code now and it works fine, please see this

    Code:
    public class Stack
    {
    	public static final int MaxStack = 5;
    	public static final int MaxMaze = 5;
    	int item[] = new int[MaxStack];
    	int mytop;
    	
    	public Stack()
    	{
    		mytop =- 1;
    	}
    	
    	public boolean IsEmpty()
    	{
    		return (mytop == -1);
    	}
    	
    	public void push(int val)
    	{
    		if (mytop == MaxStack - 1)
    		{
    			System.out.println("Stack Is Full");
    			return ;
    		}
    	item[++mytop] = val;
    	}
    	
    	public int pop()
    	{
    		if(IsEmpty())
    		{
    			System.out.println("Stack Is Empty");
    			return -1;
    		}
    		return item[mytop--];
    	}
    	
    	public static void main (String args[])
    	{
    		char[][] a = {
    				{' ',' ','*','*','*'},
    				{'*',' ','*',' ',' '},
    				{'*',' ','*',' ','*'},
    				{'*',' ',' ',' ','*'},
    				{'*','*','*','*','*'}
    				};
    		
    		Stack s1 = new Stack();
    		Stack s2 = new Stack();
    
    		int i = 0 , j = 0;
    		
    		while(j>=0 && i>=0)
    		{
    			while(i>=0 && a[i][j]!='*' && a[i][j]!='-')
    			{
    				while(j<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    				{
    					while(i<MaxMaze && a[i][j] !='*' && a[i][j]!='-')
    					{
    						a[i][j]='-';
    						s1.push(i);
    						i++;
    					}
    					i=s1.pop();
    					s2.push(j);
    					j++;
    				}
    				j=s2.pop();
    				s1.push(i);
    				i--;
    			}
    			i=s1.pop();
    			s2.push(j);
    			j--;
    		}
    		
    		for(i=0;i<MaxMaze;i++)
    		{
    			for(j=0;j<MaxMaze;j++)
    			{
    				System.out.println(a[i][j]);
    				System.out.println();
    			}
    		}
    	}
    }

Similar Threads

  1. Convert C++ Program to Java Code!! Please help
    By jessesaini in forum Software Development
    Replies: 1
    Last Post: 24-04-2012, 12:24 AM
  2. pls convert this c++ to java code
    By xSim21 in forum Software Development
    Replies: 4
    Last Post: 26-03-2012, 06:32 PM
  3. Convert C++ code into JAVA
    By Macario in forum Software Development
    Replies: 6
    Last Post: 13-11-2011, 07:36 PM
  4. Need help to convert c++ to java code program
    By xSim21 in forum Software Development
    Replies: 2
    Last Post: 27-11-2010, 04:42 PM
  5. How can I convert my java program to an .exe file?
    By Baran in forum Software Development
    Replies: 3
    Last Post: 02-03-2009, 07:04 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,721,601.47724 seconds with 17 queries