Tuesday, February 28, 2017

(13)Write a Program to enter electronics util and total bill use following condition in Cpp


Unit        Rate        Perunit
100         0              50-0
200         1              150-50
300         2              250-200
400         3              350-450
500         4              450-800
>500       5              550-1250
vProgram
#include<iostream.h>
#include<conio.h>
void main()
{
  int unit,tot;
  clrscr();
  cout<<"\n\t\t Enter Unit:";
  cin>>unit;
  if(unit>500)
  {
    tot=(unit-500)*5+1000;
   }
   else if(unit>400)
   {
     tot=(unit-400)*4+600;

   }
   else if(unit>300)
   {
     tot=(unit-300)*3+300;
   }
   else if(unit>200)
   {
    tot=(unit-200)*2+100;

   }
   else if(unit>100)
   {
     tot=(unit-100)*1;

   }
   else
   {
     tot=0;
   }
   cout<<"\n\t\t Your Total Bill Is:"<<tot;
   getch();
   }
vOutput

Enter Unit:200
Your Total bill Is:100

No comments:

Post a Comment