Saturday, 26 January 2019

Program to calculate electricity bill of a user in different cases in C++

#include <iostream.h>
#include <conio.h>
void main ()
{
char name[25];
int choice;
float cahrge1,charge2,charge3,charge4,charge5,unit1,unit2,unit3,unit4,unit5;
cout<<"\n enter name of user:";
scanf ("%s", name;
cout<<"\n you can perform following operation:";
cout<<"\n 1. below 83.33:";
cout<<"\n 2. above 83.34 to 100:";
cout<<"\n 3. above 100 to 200:";
cout<<"\n 4. above 200 to 300:";
cout<<"\n 5. above 300:";
cout<<"\n enter your choice:";
cin>>choice;
switch ( choice )
{
       case 1:       cout<<"\n enter value of units:";
       cin>>unit1;
       "cout<<\n Energy charge is 50:";
break;       case 2:       cout<<"\n enter value of units:";
       cin>>unit2;
       charge2= 0.6*unit2;
       cout<<"\n Charge="<<charge2;
break;       case 3:       cout<<"\n enter value of units:";
       cin>>unit3;
       charge3=( 0.8*(unit3-100)+60;
       cout<<"\n Charge="<<charge3;
break;
       case 4:
       cout<<"\n enter value of units:";
       cin>>unit4;
       charge4=( 0.9*(unit4-200)+140);
       cout<<"\n Charge="<<charge4;
break;
       case 5:
       cout<<"\n enter value of units:";
       cin>>unit5;
       charge5=( 0.9*(unit5-300)+230);
       charge5=charge5+0.15*(charge5);
       cout<<"\n Charge="<<charge5;
break;default:        cout<<"\n Have a nice day:";
}
getch ();
}

No comments:

Post a Comment

Featured post

Kalgudi Interview Round!!

Those who cleared the second round of kalgudi got an email from exceller to complete their Kalgudi Interview Round. So here we will discuss ...