Menu

Custom Search

C++ lab Program

#include
#include
union currency
{
int yens;
float dollars;
};
struct book
{
private:
char title[30];
char author[30];
char code;
currency price;
public:
void getdata();
void display();
} ;
void main()
{
clrscr();
book b;

b.getdata();
b.display();
getch();
}
void book::getdata()
{
cout<<"Enter title of book:"<>title;
cout<<"Enter author name:"<>author;
cout<<"Enter code(j/J for Japanese and a/A for American):"<>code;
if(code=='j'||code=='J')
{ cout<<"Enter price in yen:"<>price.yens;
}
if(code=='a'||code=='A')
{ cout<<"Enter price in doller:"<>price.dollars;
}
}
void book::display()
{
cout<<"Title:"< cout<<"Author:"< if(code=='j'||code=='J')
cout<<"Price Y"< if(code=='a'||code=='A')
cout<<"Price:$"<

}

No comments:

Post a Comment