Write a C++ Program to Print Electricity bill
Object:
Write a C++ program to print the bill. Take the units consumed Accordingly calculate amount.
- for 1st 100 units @ 1Rs.(any currency)/unit
- for next 100 units @ 2 Rs./unit
- for next 100 units @ 3 Rs./unit
- for next 200 units @ 4 Rs./unit
- for next units @ 5 Rs./unit
- tax to be added in final amount @ 10%.
- Meter charge 50 Rs. extra. Print the bill. C++ projects.
Code:
#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
void main()
{
string name;
int id;
double csm, chrg, amt, tax, total;
cout<<“\n\t**************************************************\n”;
cout<<“\t\t:E l e c t r i c i t y B i l l:\n”;
cout<<“\t**************************************************\n”;
cout<<“Enter Coustomer Name: “;
getline(cin,name);
cout<<“Enter Coustomer ID: “;
cin>>id;
cout<<“Enter the unit consumed by the customer: “;
cin>>csm;
if(csm>=0 && csm<=100)
{
amt=csm*1;
}
else if(csm>100 && csm<=200)
{
amt=((csm-100)*2)+100;
}
else if(csm>200 && csm<=300)
{
amt=((csm-200)*3)+200;
}
else if(csm>300 && csm<=400)
{
amt=((csm-300)*4)+300;
}
else
{
amt=((csm-500)*5)+1400;
}
//calculate tax
tax=(amt*10)/100;
total=amt+50+tax;
cout<<“\n\nCoustomer ID: “<<id<<endl;
cout<<“Coustomer Name: “<<name<<endl;
cout<<“Unit Consumed by Customer: “<<csm<<endl;
cout<<“Bill of Units without tax is: “<<amt<<” Rs.”<<endl;
cout<<“Meter Charges : 50 Rs.”<<endl;
cout<<“Tax is: “<<tax<<endl;
cout<<“Total Bill Pay by Customer: “<<total<<endl;
getch();
}
#include<iostream> #include<conio.h> #include<string> using namespace std; void main() { string name; int id; double csm, chrg, amt, tax, total; cout<<"\n\t**************************************************\n"; cout<<"\t\t:E l e c t r i c i t y B i l l:\n"; cout<<"\t**************************************************\n"; cout<<"Enter Coustomer Name: "; getline(cin,name); cout<<"Enter Coustomer ID: "; cin>>id; cout<<"Enter the unit consumed by the customer: "; cin>>csm; if(csm>=0 && csm<=100) { amt=csm*1; } else if(csm>100 && csm<=200) { amt=((csm-100)*2)+100; } else if(csm>200 && csm<=300) { amt=((csm-200)*3)+200; } else if(csm>300 && csm<=400) { amt=((csm-300)*4)+300; } else { amt=((csm-500)*5)+1400; } //calculate tax tax=(amt*10)/100; total=amt+50+tax; cout<<"\n\nCoustomer ID: "<<id<<endl; cout<<"Coustomer Name: "<<name<<endl; cout<<"Unit Consumed by Customer: "<<csm<<endl; cout<<"Bill of Units without tax is: "<<amt<<" Rs."<<endl; cout<<"Meter Charges : 50 Rs."<<endl; cout<<"Tax is: "<<tax<<endl; cout<<"Total Bill Pay by Customer: "<<total<<endl; getch(); }
Output:
Another Program: Write a C++ Program to calculate Sales tax.
Pingback: Write a C++ program which takes the price of bakery items ranging from 0-999
Pingback: C++ projects for beginners with source code - Codeboks