Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

19CSE201 – Advanced Programming

Lab Experiments for week1


2)Create a class Television with model number, brand, and price as data
members. Include a constructor and a member function
showTelevision() to set and print the member values respectively.
Write a main method to demonstrate the Television class.
AIM:
To create a class Television with model number, brand, and price as
data members and using a constructor and a member function
showTelevision() to set and print the member values respectively.

ALGORITHM:
1)START
2)Create a class Television with model number,brand, and price as
data members.
3)Create OR Declare a constructor in class which initializes objects of
class.
4)Include a member function showTelevision() and print the member
values.
5)In main function initialize values of data members and print output
using showTelevision()
6)STOP

PROGRAM:
#include <iostream>

using namespace std;


class Television {
public:
string mdno;
string brand;
float price;
Television(string x,string y,float z) {
mdno = x;
brand = y;
price = z;

}
void showTelevision();
};
void Television::showTelevision()
{
cout<<"Model number:"<<""<<mdno<<endl;
cout<<"Brand:"<<""<<brand<<endl;
cout<<"price:"<<""<<price<<endl;
}

int main()
{
Television obj("4A324WB2","plasma",50000);
obj.showTelevision();
return 0;
}
OUTPUT:
Model number:4A324WB2

Brand:plasma

price:50000

...Program finished with exit code 0

Press ENTER to exit console.

RESULT:
Class Television is created and constructor and a member function is
created successfully to print the values of data members.

You might also like