Revision Programs

Set 9

Mobile Bill: Slab Calculation

1. Sequence Construct

  1. Input name of a subscriber, mobile number, previous reading and present reading. Find number of calls, phone charge and print a bill. The charge is Rs. 0.80 per call.

2. Conditional Construct: Selection Statement

if

  1. Input previous reading and present reading. Find number of calls, mobile charge and print a bill. If the calls are above 50 then the charge is Rs. 0.80 per unit. (Otherwise no charge). Use simple if.

if else

  1. Input previous reading and present reading. Find the mobile charge and print a bill.
    For the first 50 calls the charge is Rs. 0.0 per unit. For remaining calls Rs. 0.80 per unit.
-->

if else if else

  1. Input previous reading and present reading. Find mobile charge and print a bill.
    For the first 50 calls the charge is Rs. 0.0 per unit.
    Next 50 calls Rs. 0.80 per unit.
    For remaining calls Rs. 1.20 per unit.

Nested if else if else

  1. No need

if After if else

  1. Input previous reading and present reading. Find mobile charge and print a bill.
    For the first 50 calls charge is Rs. 0.80 per call.
    For remaining calls Rs. 1.00 per call.
    For BSNL employees 60% reduction.

switch case

  1. No need

3. Iterative Construct (Loop):

for

  1. Input n subscribers’ names and number of calls. Find mobile charge and print a bill for each subscriber. Also find total collection.
    For first 50 calls charge is Rs. 0.80 per unit.
    Remaining calls Rs. 1.00 per unit.

4.1 S D Array:

  1. Input n subscribers’ consumer numbers, names and number of calls into three arrays. Find mobile charge of each subscriber and store them into another array. Input a search number; print the details of the subscriber. (Use binary search as the consumer numbers are in ascending order)
    For first 50 calls charge is Rs. 0.80 per unit.
    Remaining calls Rs. 1.00 per unit.

4.2. D D Array

  1. Initialize any 9 alphabets in capital to a matrix. Display the vowels in the matrix, also find count of them.

5. Methods

  1. No need

6. Constructor

  1. Define a class MobileBill. Data members: name, calls, charge.
    Member methods: 1) getData() - to input name and calls.
    2) compute() – to find mobile charge:
    First 50 units: 0.80 per unit. Next 50 units: 1.00 per unit: Remaining units: 1.20 per unit.
    3) display() – to print the bill.
    Write main() also.