1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

C++ to Java

Discussion in 'C++' started by Cyberslam, Jul 25, 2007.

  1. Cyberslam

    Cyberslam New Member

    Joined:
    Jul 25, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Are you looking for some automated tool or what because I don't see any complexity in the code you have posted.
     
  3. Cyberslam

    Cyberslam New Member

    Joined:
    Jul 25, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Maybe you want the Jobs Forum?
     
  5. Cyberslam

    Cyberslam New Member

    Joined:
    Jul 25, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    DaWei, this is not what you think it is.
     
  6. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    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.
     
  7. Cyberslam

    Cyberslam New Member

    Joined:
    Jul 25, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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.
     
  8. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    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?
     
  9. Cyberslam

    Cyberslam New Member

    Joined:
    Jul 25, 2007
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    0
    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!
     

Share This Page