Skip to content

MyUstaadG

Learn to Serve

  • Computer Science
    • Software
    • Computer Tips
    • Coding
      • Conditional Structures Exercises
      • Loops Exercises
      • Arrays Exercises
      • Python Exercises
    • Microsoft Office
      • MS Excel
      • MS Word
  • Videos
    • Funny Videos
    • Health and Fitness Videos
    • PUBG Videos
    • Technology Videos
  • News
  • Funny
  • Memes
  • Playwright Tutorials
  • Tutorials
  • Toggle search form

Write a program that inputs the current reading and previous reading of electric meter. It finds out the total units consumed using nested ‘if-else’ structure and computes the electricity bill

Posted on September 29, 2021 By myustaadg.com
Spread the love

Write a program that inputs the current reading and previous reading of electric meter. It finds out the total units consumed using nested ‘if-else’ structure and computes the electricity bill as follows:
// If units consumed are less than or equal to 300, then rate of electricity is Rs.12 per unit.
// If units consumed are more than 300 and less than or equal to 400, then rate of electricity is Rs.14 per unit.
// If units consumed are more than 400, then rate of electricity is Rs.20 per unit.

We learn Programming to solve problems using Computers. A Computer Program is the set of instructions that are given to a computer so that it can solve problems. To solve problems is our primary goal in Computer Science.

C++ is the most fundamental language to learn programs. C++ is the High-Level Language.  It is very easy to instruct computers using C++ Programming Language. My goal is to provide Practice Programs. Because As we know practice is the most fundamental aspect to learn how to program. I will provide solved programming exercises to help students.

Find All C++ Solved Programs.

What is Compiler?

A Compiler is computer software that is used to convert a C++ language program to a computer’s native language which is binary language. It is a translator program. It is used to convert Source Code into Object Code.

What is Source Code?

Any instruction that is written in High-Level Language i.e. C++ or C is known as Source Code.

What is Object Code?

Any Code that is written in Low-Level Language i.e. Assembly Language or Binary Language is known as Object Code.

So we will use Dev C++ Compiler for C++ Programming.

So let’s Write Code:

Write a program that inputs the current reading and previous reading of electric meter. It finds out the total units consumed using nested ‘if-else’ structure and computes the electricity bill as follows:
// If units consumed are less than or equal to 300, then rate of electricity is Rs.12 per unit.
// If units consumed are more than 300 and less than or equal to 400, then rate of electricity is Rs.14 per unit.
// If units consumed are more than 400, then rate of electricity is Rs.20 per unit.

#include"iostream"
using namespace std;
main()
{
unsigned int previous, current, units, bill;

cout<<"Enter previous reading ? ";
cin>>previous;
cout<<"Enter current reading ? ";
cin>>current;
units = current - previous;
if (units > 400)
bill = units * 20;
else if (units> 300)
bill = units * 14;
else if (units <= 300)
bill = units * 12;
cout << "Total units :"<<units<<endl;
cout << "Electricity bill :"<<bill;
}

Hope You will learn Something From Here:

We will Conver the Following topics or tags on this website.

Basic Programs In C++

C++ Coding Guideline

Class Programs In C++

Coding Convention C++ Namespace

Coding Examples C++

Coding Ground C++

Coding In C++ For Beginners

Coding In C++ Online

Coding With C++

Coding Websites C++

Complex Number Program In C++

Constructor Programs In C++

Data Structures Programs In C++

Example Programs In C++

Programs In C++ Examples

Exception Handling Programs In C++

For Loop Programs In C++

Function Overloading Programs In C++

Function Programs In C++

Game Programs In C++

Graphics Programs In C++

How To Create Programs In C++

How To Make Programs In C++

How To Write Programs In C++

Huffman Coding In C++

If Else Programs In C++

If Programs In C++

Implementation Of Stack Using Array In C++ Programs

In C++ Programs The Keyword Friend Appears In The

Inheritance Programs In C++

Interview Programs In C++

Number Pattern Programs In C++

Oops Programs In C++

Operator Overloading Programs In C++

Pattern Programs In C++

Programming In C++ Questions And Answers

Programs In C++ For Beginners

Programs In C++ Pdf

Programs In C++ Using Class

Programs In Turbo C++

Programs Of C++

Programs Of C++ Language

Writing Programs In C++

Structure Programs In C++

Template Program In C++

String Programs In C++

Stack Programs In C++

Sorting Programs In C++

Simple Programs In C++

Queue Program In C++

Conditional Structures Exercises Tags:Basic Programs In C++, C++ Coding Guideline, Class Programs In C++, Coding Convention C++ Namespace, Coding Examples C++, Coding Ground C++, Coding In C++ For Beginners, Coding In C++ Online, Coding Websites C++, Coding With C++, Complex Number Program In C++, Constructor Programs In C++, Data Structures Programs In C++, Dev C++, Example Programs In C++, Exception Handling Programs In C++, For Loop Programs In C++, Function Overloading Programs In C++, Function Programs In C++, Game Programs In C++, Graphics Programs In C++, How To Create Programs In C++, How To Make Programs In C++, How To Write Programs In C++, Huffman Coding In C++, if else, if else if, If Else Programs In C++, If Programs In C++, Implementation Of Stack Using Array In C++ Programs, In C++ Programs The Keyword Friend Appears In The, Inheritance Programs In C++, Interview Programs In C++, mohammad umar, myustaadg, Number Pattern Programs In C++, Object Code, Oops Programs In C++, Operator Overloading Programs In C++, Pattern Programs In C++, Programming In C++ Questions And Answers, Programs In C++ Examples, Programs In C++ For Beginners, Programs In C++ Pdf, Programs In C++ Using Class, Programs In Turbo C++, Programs Of C++, Programs Of C++ Language, Queue Program In C++, Sorting Programs In C++ Simple Programs In C++, Source Code, Stack Programs In C++, String Programs In C++, Structure Programs In C++, Template Program In C++, Writing Programs In C++

Post navigation

Previous Post: Write a program that performs simple arithmetic calculations using ‘nested if-else’ structure
Next Post: Write a program that inputs salary and computes the net salary. If the salary is 30000 or more, it deducts 13% of the salary. If the salary is 15000 or more but less than 30000, it deducts 1500 from the salary

More Related Articles

Write a program that inputs a number and calculates the square root of the number if the number is greater than 0. Otherwise it displays a message “Number is negative or zero” Conditional Structures Exercises
Write a program that inputs an integer and displays the corresponding name of day of the week using switch selection structure Conditional Structures Exercises
Write a program that inputs temperature and displays a message according to the following data Conditional Structures Exercises
Write a program in C++ that inputs a number and displays whether it is an even number or odd number Conditional Structures Exercises
Write a program that gets an integer value and tests whether the given number is odd or even using switch statement Conditional Structures Exercises
Write a program that displays the largest and smallest value entered by a user ten times in a single variable during the program execution using goto Statement Conditional Structures Exercises

Copyright © 2022 MyUstaadG.

Powered by PressBook Blog WordPress theme