Code in C++
Write a program that prompts the user for their monthly electricity bill for the last 5 months.
The program should find and output their average monthly electricity bill. If the average bill exceeds $200, the output should include a message indicating that too much Gas and Electricity is being used. If the average bill is at least $80 but no more than $300, the output should say that a typical amount of Gas and Electricity is being used. Finally, if the average bill is less than $80 the output should include a message congratulating the user for conserving Gas and Electricity.
#include <iostream> using namespace std; int main(){ double sum = 0, n; for(int i = 0;i<5;i++){ cout<<"Enter electricity bill for month "<<(i+1)<<": "; cin>>n; sum += n; } double avg = sum / 5; if(avg < 80){ cout<<"congratulations for conserving Gas and Electricity."<<endl; } else if(avg < 300){ cout<<"typical amount of Gas and Electricity is being used."<<endl; } else{ cout<<"too much Gas and Electricity is being used."<<endl; } return 0; }
Get Answers For Free
Most questions answered within 1 hours.