Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/forums/cpp/)
-   -   C++ to Java (http://www.go4expert.com/forums/cpp-to-java-t5454/)

Cyberslam 25Jul2007 13:43

C++ to Java
 
Hi all,

I have made a small simple program in C++ using Turbo C but now i want to convert it into Java. Is there anyone here who is willing to help me in this ?

Here is the source code of my program:
Code:

#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
  long phone[50];
  int count=0;
  char *name[100];
  long price[50];
  char *color[100];
  char *camera[100];
  char c1='y';
  int num=0;
while (c1=='y')
{
  clrscr();
  cout<<"Enter your choice"<<endl;
  cout<<"1.store information"<<endl;
  cout<<"2.output information"<<endl;
  cout<<"3.search for phone by phone number"<<endl;
  cout<<"4.average price of phones"<<endl;
  cout<<"5.total price of the phones entered"<<endl;
  cout<<"Enter no for operation"<<endl;
    cin>>num;
 if (num==1)
  {
    clrscr();
    char c='a';
      while (c=='a')
      {
      count++;
      int i=count;
      {
        cout<<"enter phone number"<<endl;
        cin>>phone[i];
            cout<<"enter phone name"<<endl;
            cin>>name[i];
            cout<<"enter price"<<endl;
              cin>>price[i];
            cout<<"enter color"<<endl;
            cin>>color[i];
            cout<<"camera option"<<endl;
            cin>>camera[i];
        }
  clrscr();
  cout<<"Press 'a' to continue adding phone info"<<endl;
  cin>>c;
  }

}
  if (num==2)
    {
    clrscr();
      for (int k=1;k<=count;k++)
      {
          cout<<"              phone  "<<k<<"  details "<<endl;
          cout<<"phone no: "<<phone[k]<<endl;
              cout<<"phone name: "<<name[k]<<endl;
              cout<<"phone price: "<<price[k]<<endl;
              cout<<"phone color: "<<color[k]<<endl;
              cout<<"camera present: "<<camera[k]<<endl;
      }
  getche();
}
        if (num==3)
  {
    int search=0;
    int l=1;
    char found;
    clrscr();
    cout<<"Search no of phone"<<endl;
    cin>>search;
      while (search!=phone[l])
      {
        l++;
        }
  if (search==phone[l])
  {
  cout<<"Phone no " <<l<<"  details"<<endl;
  cout<<"Phone no : "<<phone[l]<<endl;
  cout<<"Phone name : "<<name[l]<<endl;
  cout<<"Phone price : "<<price[l]<<endl;
  cout<<"Phone color : "<<color[l]<<endl;
  cout<<"Camera option : " <<camera[l];
  }
    getch();
  }
  if (num==4)
  {
    cout<<"yes\n";
    float avg=0;
    float avv=0;
    int z=0;
    for(z=1;z<=count;z++)
    {
    avg=price[z];
    avv=avv+avg;
    }
  cout<<"The Average price of the phones is :  "<<avv/2;
 getch();
}
  if(num==5)
  {
    int add=0;
    int y=0;
    for (y=1;y<=count;y++)
      {
      add=add+price[y];
    }
  cout<<"The Total amount of phone prices : ";
  cout<<add;
  getche();
    }
clrscr();
cout<<"Press 'y' to go to menu "<<endl;
cin>>c1;
}
clrscr();
cout<<"bye bye press any key to exit";
getche();
}

Thanks in advance.

shabbir 25Jul2007 15:45

Re: C++ to Java
 
Are you looking for some automated tool or what because I don't see any complexity in the code you have posted.

Cyberslam 25Jul2007 17:29

Re: C++ to Java
 
I tried searching for some automated tool but couldn't find any. So basically i just want this C++ code to be translated into Java code.

DaWei 25Jul2007 17:36

Re: C++ to Java
 
Maybe you want the Jobs Forum?

Cyberslam 25Jul2007 18:53

Re: C++ to Java
 
DaWei, this is not what you think it is.

DaWei 25Jul2007 20:30

Re: C++ to Java
 
How am I supposed to know what it is? You want it translated. You've shown no effort to translate it. The implication is that you want it translated for you (you sought a tool). That's a service. You haven't asked a single question regarding how Java does things, versus C. All you've done is presented a C program that won't even compile on many platforms.

Cyberslam 26Jul2007 01:35

Re: C++ to Java
 
How do you know that i have used no effort to translate it ? I have been to tons of website for the past 48 hours but i understand it because i have never used Java before.

DaWei 26Jul2007 01:41

Re: C++ to Java
 
How am I to know what effort you've expended? You neither told nor showed.

You don't learn Java in 48 hours, however similar the syntax might be to C/C++. I would suggest that you review your posts with an analytical and unbiased mind. I would also suggest that you still haven't indicated that you aren't looking for some free production.

If you're expecting to learn Java by posting a few things in a C forum, I'm afraid you're going to be disappointed. If you're expecting to get the work done for free, you might very well luck out. Who knows?

Cyberslam 30Jul2007 17:24

Re: C++ to Java
 
I know you don't learn Java in 48 hours and i wouldn't have posted on this forum if i had time to learn Java. I will be very frank, i am not intered in programming at all. I just wanted this thing done for a small assignment of college.

Anyways, i don't have to explain all this to you. Good Day!


All times are GMT +5.5. The time now is 20:52.