google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: February 2015

Saturday, February 28, 2015

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

Write a C++ program using class to sort an integer array and float array element in ascending order using bubble sort method use function overloading

#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<float.h>
class bubble
{
public:void array(int ans);
       void array(float ans);
};
void bubble:: array(int ans)
       {
       cout<<"\n"<<ans;
       }
void bubble::array(float ans)
       {
       cout<<"\n"<<ans;
       }
int main()
{
bubble bb;
int i,j,n,a[20],temp=0;
float b[20];
clrscr();
cout<<"\n Enter how many integer number you want to enter:-";
cin>>n;
for(i=0;i<n;i++)
cin>>a[i];
n=n-1;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
n++;
cout<<"\n Integer array after sorting:-";
for(i=0;i<n;i++)
bb.array(a[i]);
cout<<"\n Enter how many float number you want to enter:-";
cin>>n;
for(i=0;i<n;i++)
cin>>b[i];
n=n-1;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(b[j]>b[j+1])
{
float(temp)=b[j];
b[j]=b[j+1];
b[j+1]=float(temp);
}
}
}
n++;
cout<<"\n Float array after sorting:-";
for(i=0;i<n;i++)
bb.array(b[i]);
getch();

return 0;
}

==================================================
OUTPUT

Enter how many integer number you want to enter:-5                             
9                                                                              
8                                                                              
7                                                                              
4
1                                                                              
                                                                               
Integer array after sorting:-                                                  
1                                                                              
4                                                                              
7                                                                              
8                                                                              
9  
                                                                           
Enter how many float number you want to enter:-4                               
6.3                                                                            
5.2                                                                            
4.2                                                                            
1.3                                                                            
                                                                               
Float array after sorting:-
1.3
4.2
5.2
6.3

Write a C++ program to Design a class which contain static data member and member function show()

Design a class which contain static data member and member function show() which display number of times display operation is performed irrespective of the object responsible for display using static data
member.

#include<conio.h>
#include<iostream.h>
class number
{
public:static int cnt;
public:static void show()
       {
       cnt++;
       cout<<"\n Number of times display operation is performed:-"<<cnt;
       }
};
int number::cnt;
int main()
{
number n1,n2,n3,n4;
clrscr();
n1.show();
n2.show();
n3.show();
n4.show();
getch();
return 0;
}


==================================================
OUTPUT

Number of times display operation is performed:-1
Number of times display operation is performed:-2
Number of times display operation is performed:-3
Number of times display operation is performed:-4

Write a c++ program using class to calculate cube and square of a given number using inline function.

Write a c++ program using class to calculate cube and square of a given number using inline function.

#include<iostream.h>
#include<conio.h>
class calc
{
int no;
public:inline void number()
       {
       int square,cube;
       cout<<"Enter the number";
       cin>>no;
       square=no*no;
       cube=no*no*no;
       cout<<"Square of a given number is:-"<<square;
       cout<<"\n Cube of a given number is:-"<<cube;
       }
       };
int main()
{
calc c;
clrscr();
c.number();
getch();
return 0;
}

======================================================
OUTPUT:-
Enter the number5
Square of a given number is:-25
Cube of a given number is:-125

Write a c++ program using class to overload the operator unary decrement -- for an integer number.

Write a c++ program using class to overload the operator unary decrement -- for an integer number.


#include<conio.h>
#include<iostream.h>
class decrement
{
public:int no;
public:void getdata()
       {
       cout<<"\n Enter the number:-";
       cin>>no;
       }
       void operator --()
       {
       no=no-1;
       }
       void display()
       {
       cout<<"\n The number after decrement is:-"<<no;
       }
};
int main()
{
decrement i;
clrscr();
i.getdata();
--i;
i.display();
getch();
return 0;
}








==================================================
OUTPUT

Enter the number:-6

The number after decrement is:-5

Write a c++ program using class to overload the operator unary increment ++ for an integer number.

Write a c++ program using class to overload the operator unary increment ++ for an integer number.


#include<conio.h>
#include<iostream.h>
class increment
{
public:int no;
public:void getdata()
       {
       cout<<"\n Enter the number:-";
       cin>>no;
       }
       void operator ++()
       {
       no=no+1;
       }
       void display()
       {
       cout<<"\n The number after increment is:-"<<no;
       }
};
int main()
{
increment i;
clrscr();
i.getdata();
++i;
i.display();
getch();
return 0;
}


=========================================

OUTPUT
Enter the number:-2

The number after increment is:-3

Friday, February 27, 2015

VB program to dispaly age from birth date

Design Window:-


Code:

Private Sub cmdClear_Click()
    Text1.Text = ""
    Text2.Text = ""
    Text1.SetFocus
End Sub

Private Sub cmdDisplay_Click()
    Dim b As Date
    Dim d As Date
    Dim age As Date
    b = Text1.Text
    d = Format$(Now, "dd/mm/yyyy hh:mm:ss ")
    age = Format$(d - b, "dd/mm/yyyy hh:mm:ss")
   
    Text2.Text = Year(age)
    Text3.Text = Month(age)
    Text4.Text = Day(age)
    Text5.Text = Hour(age)
    Text6.Text = Minute(age)
    Text7.Text = Second(age)
End Sub

Private Sub cmdExit_Click()
    Unload Me
End Sub
===================================================
OUTPUT

Thursday, February 26, 2015

Write a c++ program using class to read the name of user and number of units consumed and printout charges with name(Electricity)

An electricity board charges the following rates to users
-for first 100 units:40p per unit
-for next 200 units: 50p per unit
-for beyond 300 units :60p per unit
all user are charged a minimum of Rs.150. if the total cost is more
than Rs.250 then an additional charges of 15% are added.
write a c++ program using class to read the name of user and number
of units consumed and printout charges with names.(use array of object)



#include<conio.h>
#include<iostream.h>
class elec
{
char name[20];
int nou;
float charge;
public:void accept()
       {
       cout<<"\n enter name:-";
       cin>>name;
       cout<<"\n enter number of unit:-";
       cin>>nou;
       }
       void calc()
       {
       if(nou<100)
       charge=nou*0.4;
       else
       if(nou<=300)
       {
       int temp=nou-100;
       charge=100*0.4;
       charge=(float)charge+(temp*0.5);
       }
       else
       if(nou>300)
       charge=nou*0.6;
       if(charge<150)
       charge=150;
       else
       if(charge>250)
       charge=(float)charge+(charge*0.15);
       }
       void display()
       {
       cout<<"\n name="<<name;
       cout<<"\n charges="<<charge;
       }
};
int main()
{
elec e[3];
clrscr();
for(int i=0;i<3;i++)
{
e[i].accept();
e[i].calc();
}
for(i=0;i<3;i++)
e[i].display();
getch();
return 0;
}

=============================================
OUTPUT:-

enter name:-XYZ                                                             
                                                                               
enter number of unit:-122                                                      
                                                                               
enter name:-ABC                                                                
                                                                               
enter number of unit:-302                                                      
                                                                               
enter name:-PQR                                                             
                                                                               
enter number of unit:-1000                                                     
                                                                               
name=XYZ                                                                    
charges=150                                                                    
name=ABC                                                                      
charges=181.199997                                                             
name=PQR
charges=690

Write a C++menu driven program to show class hierarchy.

Consider the following class hierarchy.
    Create a base class Employee(empcode, empname). Derive the classes Manager(designation, clubdues), Scientist(deptname, publications) and Labourer from
Employee class. Write a C++ menu driven program
1.    to accept  the details of ‘n’ employees
2.    to display the information
3.    to display all the scientist from “Chemistry Department”.


#include<conio.h>
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
char ans[20];
int ch,n,a=0,b=0,i,cnt;
class employee
{
protected:int empcode;
       char empname[20];
};
class manager:protected employee
{
protected:char desg[20];
      int dues;
public:void accept1();
       void display1();
}m[10];
void manager::accept1()
{
cout<<"\n enter employee code:-";
cin>>empcode;
cout<<"\n enter employee name:-";
cin>>empname;
cout<<"\n enter designation:-";
cin>>desg;
cout<<"\n enter club-dues:-";
cin>>dues;
}
void manager::display1()
{
cout<<empcode<<"\t"
<<empname<<"\t"
<<desg<<"\t"
<<dues<<"\n";
}
class scientist:protected employee
{
protected:char dept[20],pub[20];
public:void accept2();
       void display2();
       void search(char name[20]);
}s[10];
void scientist::accept2()
{
cout<<"\n enter employee code:-";
cin>>empcode;
cout<<"\n enter employee name:-";
cin>>empname;
cout<<"\n enter department name:-";
cin>>dept;
cout<<"\n enter the publication:-";
cin>>pub;
}
void scientist::display2()
{
cout<<empcode<<"\t"
<<empname<<"\t"
<<dept<<"\t"
<<pub<<"\n";
}
void scientist::search(char name[20])
{
int i,cnt;
for(i=0;i<b;i++)
      {
       cnt=strcmp(name,ans);
       if(cnt==0)
       cout<<"\n scientist is chemistry department is:-"<<s[i].empname;
       }
}
int main()
{
int temp;
clrscr();
while(1)
{
cout<<"\n 1:accept the details";
cout<<"\n 2:display the information";
cout<<"\n 3:to display all the scientist of chemistry department";
cout<<"\n 4:exit";
cout<<"\n enter your choice";
cin>>ch;
switch(ch)
{
case 1:cout<<"\n enter how many employee:-";
       cin>>n;
       for(i=0;i<n;i++)
       {
       cout<<"\n whose information you want to enter";
       cout<<"\n press 1:for manager";
       cout<<"\n press 2:for scientist";
       cin>>temp;
       if(temp==1)
       m[a++].accept1();
       else
       s[b++].accept2();
       }
       break;
case 2:for(i=0;i<a;i++)
       m[i].display1();
       for(i=0;i<b;i++)
       s[i].display2();
       break;
case 3:strcpy(ans,"chemistry");
       s[i].search(ans);
       break;
case 4:exit(0);
default:cout<<"\n you entered wrong choice";
       }
}
getch();
return 0;
}


===============================================
OUTPUT

enter your choice1

enter how many employee:-2

whose information you want to enter
press 1:for manager                                                            
press 2:for scientist                                                          
1                                                                              

enter employee code:-112                                                             
                                                                               
enter employee name:-XYZ                                                            
                                                                               
enter designation:-ABC                                                        
                                                                               
enter club-dues:-75                                                             
                                                                               
whose information you want to enter                                            
press 1:for manager                                                            
press 2:for scientist                                                          
2
                                                                               
enter employee code:-120.                                                            
                                                                               
enter employee name:-                                                                
enter department name:-chemistry                                                
                                                                               
enter the publication:-pqr                                                     

1:accept the details                                                           
2:display the information                                                      
3:to display all the scientist of chemistry department                         
4:exit                                                                         
enter your choice2                                                             
112     XYZ     ABC      75                                                     
120     .       chemistry        pqr                                            
                                                                               
1:accept the details                                                           
2:display the information                                                      
3:to display all the scientist of chemistry department                         
4:exit
enter your choice3

scientist is chemistry department is:-.
1:accept the details
2:display the information
3:to display all the scientist of chemistry department
4:exit
enter your choice4

Write a C++ program to create class currency using operator overloading

Write a C++ program to create class currency using operator overloading:


Create a class currency containing rupees and paisa as data members.
Write a necessary member function using operator overloading for the following.
1.currency(long int rup=0,int paisa=0)
2.currency &operator +=(currency &)to add one currency to another
3.currency & operator -=(currency &) to subtracts one currency from another accept rupees & paisa from user and display it.



#include
#include
class currency
{
int r,p;
public:currency(long int rs=0,int paisa=0)
       {
       r=rs;
       p=paisa;
       }
       currency  & operator +=(currency &);
       currency  & operator -=(currency &);
};
currency & currency :: operator +=(currency &c2)
{
int a,b;
a=r+c2.r;
b=p+c2.p;
if(b>=100)
{
b=b-100;
a=a+1;
}
cout<<"\n Addition of two currency is:-";
cout<<"\n Rupees:-"<<a;
cout<<"\n Paisa:-"<<b;
return *this;
}
currency & currency::  operator -=(currency &c2)
{
int a,b;
a=r-c2.r;
b=p-c2.p;
cout<<"\n Subtraction of two currency is:-";
cout<<"\n Rupees:-"<<a;
cout<<"\n Paisa:-"<<b;
return *this;
}
int main()
{
int rs,paisa;
clrscr();
cout<<"\n\t\t Accept two currency \n\n";
cout<<"\n Enter rupees:-";
cin>>rs;
cout<<"Enter paisa";
cin>>paisa;
currency c1(rs,paisa);
cout<<"\n Enter rupees:-";
cin>>rs;
cout<<"Enter paisa";
cin>>paisa;
currency c2(rs,paisa);
c1+=c2;
c1-=c2;
getch();
return 0;
}


===================
OUTPUT:-

        Accept two currency


Enter rupees:-12
Enter paisa34
Enter rupees:-45
Enter paisa34
Addition of two currency is:-
Rupees:-57
Paisa:-68
Subtractions of two currency is:-
rupees:--33
paisa:-0

Write a C++ program to reverse case of each alphabet in the string

Consider the following class mystring
class mystring
{
char str[100];
public:\\methods
};
overload operator "!" to reverse case of each alphabet in the string


#include<iostream.h>
#include<string.h>
#include<conio.h>
class mystring
{
char str[100];
public:void accept()
       {
       cout<<"\n Enter string:-";
       cin>>str;
       }
       void operator !();
};
void mystring::operator !()
       {
       int len;
       len=strlen(str);
       cout<<"\n Reverse string is:-";
       for(int i=len-1;i>=0;i--)
       cout<<str[i];
       }
int main()
{
mystring m1;
clrscr();
m1.accept();
!m1;
getch();
return 0;
}



======================================================
OUTPUT :-

Enter string:-stop

Reverse string is:-pots

Monday, February 23, 2015

Write a visual basic program for stopwatch

Write a visual basic program for stopwatch:-

Design Window:-


Code:-

Dim starttime As Date
Dim s As Date
Private Sub Reset_Click()
Timer1.Enabled = False
starttime = Now
Timer1.Enabled = True
End Sub

Private Sub Start_Click()
starttime = Now
Timer1.Enabled = True
End Sub

Private Sub Stop_Click()
Timer1.Enabled = False
Label1.Caption = ""
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
End Sub

Private Sub Pause_Click()
If Pause.Caption = "Pause" Then
Timer1.Enabled = False
s1 = Label1.Caption
Pause.Caption = "Play"
End If
If Pause.Caption = "Play" Then
    Label1.Caption = s1
    Timer1.Enabled = True
End If
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Format$(Now - starttime, "hh:mm:ss:ms")
End Sub

============================================
OUTPUT



Write a visual program to calculate average using runtime textbox

Write a visual program to calculate average using runtime text-box
Design window:-

Code:

Dim t1 As TextBox
Dim t2 As TextBox
Dim t3 As TextBox
Dim t4 As TextBox
Dim a As Integer
Dim b As Integer
Dim c As Integer

Private Sub cmdClear_Click()
t1.Text = ""
t2.Text = ""
t3.Text = ""
t4.Text = ""
t1.SetFocus
End Sub

Private Sub cmdDisplay_Click()
 a = Val(t1.Text)
 b = Val(t2.Text)
 c = Val(t3.Text)
 t4.Text = (a + b + c) / 3
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub
Private Sub Form_Activate()
    Set t1 = Controls.Add("VB.TextBox", "t1")
    t1.Visible = True
    t1.Height = 600
    t1.Width = 2200
    t1.Top = 100
    t1.Left = 3200
    t1.SetFocus
           
    Set t2 = Controls.Add("VB.TextBox", "t2")
    t2.Visible = True
    t2.Height = 600
    t2.Width = 2200
    t2.Top = 800
    t2.Left = 3200
       
    Set t3 = Controls.Add("VB.TextBox", "t3")
    t3.Visible = True
    t3.Height = 600
    t3.Width = 2200
    t3.Top = 1500
    t3.Left = 3200
       
    Set t4 = Controls.Add("VB.TextBox", "t4")
    t4.Visible = True
    t4.Height = 600
    t4.Width = 2200
    t4.Top = 2200
    t4.Left = 3200
End Sub

=============================================
OUTPUT


Write a Visual Basic program to implement the find and replace dialogue box for text-box

Design an application in Visual Basic to implement the find and replace dialogue box for text-box control with multiple line of text with 3 option buttons and check boxes

Design window of form:-

Code:-
Dim txt As String
Dim s, l, r As Integer
Private Sub Check1_Click(Index As Integer)
    If Check1(0).Value = 1 Then
        Text1.Font.Bold = True
    Else
        Text1.Font.Bold = False
    End If
    If Check1(1).Value = 1 Then
        Text1.Font.Italic = True
    Else
        Text1.Font.Italic = False
    End If
    If Check1(2).Value = 1 Then
        Text1.Font.Underline = True
    Else
        Text1.Font.Underline = False
    End If
End Sub

Private Sub cmdClear_Click()
Option1(0).Value = False
Option2(1).Value = False
Option3(2).Value = False

Check1(0).Value = 0
Check2(1).Value = 0
Check3(2).Value = 0
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdFind_Click()
txt = InputBox("enter Text to find")
l = Len(txt)
r = InStr(1, Text1.Text, txt, vbTextCompare)
Text1.SelStart = r - 1
Text1.SelLength = l
End Sub

Private Sub cmdFindNext_Click()
If r <> Len(Text1.Text) Then
    r = InStr(r + 1, Text1.Text, txt, vbTextCompare)
    Text1.SelStart = r - 1
    Text1.SelLength = l
Else
    MsgBox "No more Text", vbInformation, "Find"
End If
End Sub

Private Sub cmdReplace_Click()
txt1 = InputBox("Enter text to replace")
Text1.Text = Replace(Text1.Text, txt, txt1)

End Sub

Private Sub Form_Load()
Text1.Text = "Design an application in VB to implement the find and replace dialogue " & _
            "box for textbox control with multiple line of text with 3 option buttons and check boxes and"
End Sub

Private Sub Option1_Click(Index As Integer)
If Option1(0).Value = True Then
    Text1.Font.Name = "Arial"
ElseIf Option1(1).Value = True Then
    Text1.Font.Name = "Arial Black"
Else
    Text1.Font.Name = "Times New Roman"
End If
End Sub


=================================================
OUTPUT


Write a Visual Basic Program to make customer Survey and with their name and then display the survey result.

Write a Visual Basic Program to make customer Survey and  with their name and then display the survey result.
------------------------------------------------------------------------------------------
Design Window:-
 First Form :-

Second form:-

Code;-
Dim Excellent As Integer
Dim Satisfactory As Integer
Dim Average As Integer
Dim Bad As Integer
Dim Total As Integer

Private Sub cmdContinue_Click()
If optExcellent.Value Then
    Excellent = Excellent + 1
ElseIf optSatisfactory.Value Then
    Satisfactory = Satisfactory + 1
ElseIf optAverage.Value Then
    Average = Average + 1
Else
    Bad = Bad + 1
End If
txtName.Text = ""
optExcellent.Value = False
optSatisfactory.Value = False
optAverage.Value = False
optBad.Value = False
txtName.SetFocus
End Sub

Private Sub cmdQuit_Click()
Total = Excellent + Satisfactory + Average + Bad
With frmServeyResult
    .lblExcellent = Excellent
    .lblSatisfactory = Satisfactory
    .lblAverage = Average
    .lblBad = Bad
    .lblExcellentPer = Format((Excellent / Total) * 100, "#0.00")
    .lblSatisfactoryPer = Format((Satisfactory / Total) * 100, "#0.00")
    .lblAveragePer = Format((Average / Total) * 100, "#0.00")
    .lblBadPer = Format((Bad / Total) * 100, "#0.00")
End With
frmServeyResult.Show
Unload Me
End Sub

========================================
OUTPUT
After entry of six customers response of first form survey result is:-



Write a Visual Basic program to find the mouse position on screen and number click made by user on screen.

Write a Visual Basic program to find the mouse position on screen and number click that is Left, Right and Double made by user on screen form .

First Design Form Window (mousepose.frm):-


Second Design Form Window (summary.frm):-

Code:- for first form

Dim cnt As Integer
Dim cnt1 As Integer
Dim cnt2 As Integer

Private Sub Command1_Click()
Form2.Show
Form2.Text1.Text = cnt
Form2.Text2.Text = cnt1
Form2.Text3.Text = cnt2
End Sub

Private Sub Form_DblClick()
cnt2 = cnt2 + 1
LblDblClick.Caption = cnt2
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
    cnt = cnt + 1
    LblLeftClick.Caption = cnt
End If
If Button = vbRightButton Then
    cnt1 = cnt1 + 1
    LblRightClick.Caption = cnt1
End If

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strpos As String
Dim xpos As Integer
Dim ypos As Integer

xpos = X
ypos = Y
strpos = "x : " & xpos & "   y : " & ypos
Label1.Caption = strpos
End Sub

Private Sub form_load()
cnt = 0
cnt1 = 0
End Sub

Private Sub LblRightClick_Click()

End Sub



------------------------


Code for Second form summary form:-
Design Window:-

Private Sub Command2_Click()
Unload Me
End Sub
============================================
OUTPUT




Second Output of Summary :-




Write a Visual Basic program to calculate Sum of the Even digits of a given number.

 Write a Visual Basic program to calculate Sum of the Even digits of a given number.
Designing window :-
Take the following tools form toolbox in form.




Code:-

Private Sub cmdClear_Click()
Text1.Text = ""
Text2.Text = ""
Text1.SetFocus
End Sub

Private Sub cmdSum_Click()
    n = Val(Text1.Text)
    While n > 0
        r = n Mod 10
        n = n \ 10
        If r Mod 2 = 0 Then
            s = s + r
        End If
        Text2.Text = s
    Wend
End Sub

Private Sub cmFxit_Click()
Unload Me
End Sub

Private Sub Form_Activate()
Text1.SetFocus
End Sub

===================================
OUTPUT



Write a visual Basic Program to show tool bar

Designing Window :-
First step right click on toolbox and add components it will show components popup window from it on control tab add Microsoft Windows Common Controls 6.0 (SP6) click on check box of selected items only and then click on OK button .It will show more tools like tool bar and image list on toolbox take it on form window and write the below code in coding window.


                            Fig :- Design View of program for taking tool bar on form


Code:-

Private Sub Form_Load()
Toolbar1.ImageList = ImageList1
Dim b1 As Button
Set b1 = Toolbar1.Buttons.Add
b1.Style = tbrDefault
b1.Caption = "New"
b1.Image = 1

Dim b2 As Button
Set b2 = Toolbar1.Buttons.Add
b2.Style = tbrDefault
b2.Caption = "Open"
b2.Image = 2

Dim b3 As Button
Set b3 = Toolbar1.Buttons.Add
b3.Style = tbrDefault
b3.Caption = "Save"
b3.Image = 3

Dim b4 As Button
Set b4 = Toolbar1.Buttons.Add
b4.Style = tbrDefault
b4.Caption = "Copy"
b4.Image = 4

Dim b5 As Button
Set b5 = Toolbar1.Buttons.Add
b5.Style = tbrDefault
b5.Caption = "Paste"
b5.Image = 5
End Sub


=============================================
OUTPUT


Write a C++ program to calculate area of circle,sphere and cylinder using base class round-shape

Create a base class round-shape(radius). define three different
shapes as circle, sphere and cylinder(height) from round-shape.
class round-shape
{
protected :float radius;
public:static float pi;
round-shape(float)//default argument
virtual float area()=0;
}
Write a C++ program to calculate area of circle,sphere and cylinder



#include<iostream.h>
#include<conio.h>
class round
{
protected:float radius;
public:static float pi;
       round(float r=0)
       {
       cout<<"\n Enter the radius:-";
       cin>>r;
       radius=r;
       }
       virtual float area()=0;
       };
class circle:public round
{
public:float circle;
       float area()
       {
       circle=pi*radius*radius;
       cout<<"\n Area of circle:-"<<circle;
       return 0;
       }
       };
class sphere:public round
{
public:float sph;
       float area()
       {
       sph=4*pi*radius*radius;
       cout<<"\n Area of sphere:-"<<sph;
       return 0;
       }
};
class cylinder:public round
{
public:float ac;
       float h;
public:cylinder(float height=0)
       {
       cout<<"\n Enter height:-";
       cin>>height;
       h=height;
       }
       float area()
       {
       float tsac,csac,vc,acbc;
       tsac=2*pi*radius*(h+radius);
       csac=2*pi*radius*h;
       vc=pi*radius*radius*h;
       acbc=pi*radius*radius;
       ac=tsac+csac+vc+acbc;
       cout<<"Area of cylinder is:-"<<ac;
       return 0;
       }
};
float round::pi=3.14;
int main()
{
int height;
clrscr();
cout<<"\n\t\t To calculate area of circle\n\n";
circle c;
c.area();
cout<<"\n\t\t To calculate area of sphere\n\n";
sphere s;
s.area();
cout<<"\n\t\t To calculate area of cylinder\n\n";
cylinder cl;
cl.area();
getch();
return 0;
}






============================================
OUTPUT

                To calculate area of circle                                    
                                                                               
                                                                               
Enter the radius:-1                                                           
                                                                               
Area of circle:-3.14         
                                                 
                To calculate area of sphere                                    
                                                                               
                                                                               
Enter the radius:-1                                                           
                                                                               
Area of sphere:-12.56  
                                                       
                To calculate area of cylinder                                  
                                                                               
                                                                               
Enter the radius:-1                                                           
                                                                               
Enter height:-1
Area of cylinder is:-25.120001

Write a cpp program for car passing through toll booth

Imagine a tollbooth at a bridge. a car passing by the booth
is expected to pay a toll. the tollbooth keeps the track of the number
car that gone and total cash amount collected.
create a class tollbooth with the data member
-total number of cars passed
-total toll collected
write necessary member function
1.a constructor that initializes both data member to zero.
2.paying ca(): when any cars passes through the tollbooth. that much
toll gets added into total toll collected and total number of cars passed is
incremented by one
3. nonpaying car(); increment the car total but adds nothing to cash total
4.display(); the total number car passed and total cash collected


#include<iostream.h>
#include<conio.h>
class toolbath
{
int noc,tot;
public:tollbooth(int n=0,int t=0)
       {
       noc=n;
       tot=t;
       }
       void pay()
       {
       int i;
       noc++;
       cout<<"\n Enter the amount to pay toll:-";
       cin>>i;
       tot=tot+i;
       }
       void non_pay()
       {
       noc++;
       }
       void display()
       {
       cout<<"\n Total number of car passed:-"<<noc;
       cout<<"\n Total toll collected:-"<<tot;
       }
};
int main()
{
int n,t,ans;
char ch='y';
clrscr();
cout<<"\n Enter total number of car passed:-";
cin>>n;
cout<<"\n Enter total toll collected:-";
cin>>t;
tollbooth b(n,t);
while(ch=='y'||ch=='Y')
{
cout<<"\n Enter the car type:-";
cout<<"\n Press 1: for paying car";
cout<<"\n Press 2: for non-paying car";
cin>>ans;
if(ans==1)
b.pay();
if(ans==2)
b.non_pay();
cout<<"\n Do you want to continue(Y|N):-";
cin>>ch;
}
b.display();
getch();
return 0;
}

=========================================================
OUTPUT

Enter total number of car passed:-123                                          
                                                                               
Enter total toll collected:-7478                                               
                                                                               
Enter the car type:-                                                           
Press 1: for paying car                                                        
Press 2: for non-paying car1                                                   
                                                                               
Enter the amount to pay toll:-12                                               
                                                                               
Do you want to continue(Y|N):-y                                                
                                                                               
Enter the car type:-                                                           
Press 1: for paying car                                                        
Press 2: for non-paying car1                                                   
                                                                               
Enter the amount to pay toll:-14                                               
                                                                               
Do you want to continue(Y|N):-y                                                

Enter the car type:-
Press 1: for paying car
Press 2: for non-paying car2

Do you want to continue(Y|N):-n

Total number of car passed:-126
Total toll collected:-7504

शिव भोलेनाथ स्तुति

 जय शिवशंकर, जय गंगाधर, करुणा-कर करतार हरे,   जय कैलाशी, जय अविनाशी, सुखराशि, सुख-सार हरे जय शशि-शेखर, जय डमरू-धर जय-जय प्रेमागार हरे,   जय ...