Cant run program

please somebody help me about this code.this program consist of few error when i compile it on turbo c++.
please give me executable program.



#include<iostream>
#include<conio>
#include<string>
using namespace std;
class television
{
public:
int model;
int price;
int size;
television()
{
model=size=price=0;
}
friend void operator>>(istream &din,television &tv)
{
cout<<"\n\nEnter model : ";
din>>tv.model;
if(tv.model>9999)
{
throw tv.model;
}
cout<<"\n\nEnter size : ";
din>>tv.size;
if(tv.size<12 || tv.size>70)
{
throw tv.size;
}
cout<<"\n\nEnter price : ";
din>>tv.price;
if(tv.price<0 || tv.price>5000)
{
throw tv.price;
}
}
void set()
{
model=price=size=0;
}
friend void operator<<(ostream &dout,television &tv)
{
dout<<"\n\nModel : "<<tv.model;
dout<<"\n\nSize : "<<tv.size;
dout<<"\n\nprice : "<<tv.price;
}
};

void main()
{
television t;
trycry
{
cin>>t;
}
catch(int)
{
cout<<"\n\nException caught";
t.set();
}
catch(float n)
{
cout<<"\n\nException caught";
t.set();
}
catch(double n)
{
cout<<"\n\nException caught";
t.set();
}
cout<<t;
getch();
}

Last edited on
Could you edit this code to use the code tags please? It makes it so much easier on us.

Also, you need to provide us with some insight on what is actually wrong. What errors is the compiler yelling at you? We can't spend half an hour sorting through your code without direction. :)
Last edited on
#include<iostream>
#include<conio>
#include<string>
using namespace std;
class television
{
public:
int model;
int price;
int size;
television()
{
model=size=price=0;
}
friend void operator>>(istream &din,television &tv)
{
cout<<"\n\nEnter model : ";
din>>tv.model;
if(tv.model>9999)
{
throw tv.model;
}
cout<<"\n\nEnter size : ";
din>>tv.size;
if(tv.size<12 || tv.size>70)
{
throw tv.size;
}
cout<<"\n\nEnter price : ";
din>>tv.price;
if(tv.price<0 || tv.price>5000)
{
throw tv.price;
}
}
void set()
{
model=price=size=0;
}
friend void operator<<(ostream &dout,television &tv)
{
dout<<"\n\nModel : "<<tv.model;
dout<<"\n\nSize : "<<tv.size;
dout<<"\n\nprice : "<<tv.price;
}
};

void main()
{
television t;
trycry
{
cin>>t;
}
catch(int)
{
cout<<"\n\nException caught";
t.set();
}
catch(float n)
{
cout<<"\n\nException caught";
t.set();
}
catch(double n)
{
cout<<"\n\nException caught";
t.set();
}
cout<<t;
getch();
}


WHAT IS OUTPUT OF THIS PROGRAM
IT CAN OCCUR THE SOME ERROR PLEASE CORRECT THIS ERROR

#include<iostream.h>
//#include<conio>
#include<string.h>
//using namespace std;
class television
{
public:
int model;
int price;
int size;
int throw;
television()
{
model=size=price=0;
}
friend void operator>>(istream &din,television &tv)
{ int throw;
cout<<"\n\nEnter model : ";
din>>tv.model;
if(tv.model>9999)
{
throw tv.model;
}
cout<<"\n\nEnter size : ";
din>>tv.size;
if(tv.size<12 || tv.size>70)
{
throw tv.size;
}
cout<<"\n\nEnter price : ";
din>>tv.price;
if(tv.price<0 || tv.price>5000)
{
throw tv.price;
}
}
void set()
{
model=price=size=0;
}
friend void operator<<(ostream &dout,television &tv)
{
dout<<"\n\nModel : "<<tv.model;
dout<<"\n\nSize : "<<tv.size;
dout<<"\n\nprice : "<<tv.price;
}
};

void main()
{ int trycry;
television t;
trycry;
{
cin>>t;
}
catch();
{
cout<<"\n\nException caught";
t.set();
}
/*catch(float n)
{
cout<<"\n\nException caught";
t.set();
}
catch(double n)
{
cout<<"\n\nException caught";
t.set();
}*/
cout<<t;
//getch();
}

Last edited on
use google to find query
Topic archived. No new replies allowed.