C++ Language
#include<iostream.h> #include<conio.h> class bill { private: long int phn; float pay payment,units; char name[10]; public: void getdata() { cout<<"Enter name of customer - "<<endl; cin>>name; cout<<"Enter phone number of customer - "<<endl; cin>>phn; cout<<"Enter units consumed - "<<endl; cin>>units; } void display() { cout<<"Name - "<<name<<endl; cout<<"Phone no - "<<phn<<endl; if(units<=100) { payment=1*units; cout<<"YOUR PAYMENT FOR BILL IS - "<<payment<<endl; } else if(units>=200 && units<=300) { payment=2*units; cout<<"YOUR PAYMENT FOR BILL IS - "<<payment<<endl; } else { payment=3*units; cout<<"YOUR PAYMENT FOR BILL IS - "<<payment<<endl; } } }; void main() { clrscr(); bill b; b.getdata(); b.display(); getch(); } /*OUTPUT*/ Enter name of customer - Alex Enter phone number of customer - 9999999999 Enter units consumed - 200 Name - Alex Phone - no 9999999999 YOUR PAYMENT FOR BILL IS - 400