Mar 6, 2013 at 4:00am UTC
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 Mar 6, 2013 at 4:36am UTC
Mar 6, 2013 at 4:03am UTC
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 Mar 6, 2013 at 4:04am UTC
Mar 6, 2013 at 4:34am UTC
#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();
}
Mar 6, 2013 at 4:36am UTC
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 Mar 6, 2013 at 4:37am UTC