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.