Simple c++ coding to find out monthly telephone bill using while loop id if else statement.

S

#include<iostream>

#include<conio.h>

using namespace std;

int main()

{

    int si,calls;

    float bill;

    while(true)

    {

        cout<<"enter the serial number"<<endl;

        cin>>si;

        if(si==0)

        {

            break;

        }

        cout<<"enter the number of calls"<<endl;

        cin>>calls;

        if(calls<=100)

        {

            bill=200;

        }

 

        else if(calls>100 && calls<=150)

        {

            calls=calls-100;

            bill=200+(calls*0.60);

        }

         else if(calls>150 && calls<=200)

        {

            calls=calls-150;

            bill=200+(50*0.60)+(calls*0.50);

        }

         else

        {

            calls=calls-200;

            bill=200+(50*0.60)+(50*0.50)+(calls*0.40);

        }

        cout<<"the total bills tk ="<<bill<<endl;

    }

    getch();

}

Comments