Object

Write a program to calculate gross pay of employees when basic pay is inputted. If the basic pay < 1500, house rent is 70% of basic pay and conveyance allowance is 20% of the basic pay. But if basic pay >= 1500, house rent is 60% of basic pay and conveyance allowance is 10% of the basic pay.

Algorithm

  1. Declare float variables bp, hr, ca and gp.
  2. Read bp.
  3. IF bp < 1500, then
    • hr = (70/bp)*100.
    • ca = (20/bp)*100.
    • gp = bp+hr+ca.
    • Write gp.
    • ELSE
      • hr = (60/bp)*100.
      •  ca = (10/bp)*100.
      • gp = bp+hr+ca.
      • Write gp.
    • [End of IF-ELSE structure.]
  4. Exit.

Flowchart

C++ Source Code

// program 25
#include<iostream>
using namespace std;

int main()
{
  float bp, hr, ca, gp;
  cout << "Enter basic pay: ";
  cin >> bp;

  if (bp < 1500)
  {
    hr = (70.0 / 100.0) * bp;
    ca = (20.0 / 100.0) * bp;
    gp = bp + hr + ca;
    cout << "The gross pay is: " << gp;
  }
  else
  {
    hr = (60.0 / 100.0) * bp;
    ca = (10.0 / 100.0) * bp;
    gp = bp + hr + ca;
    cout << "The gross pay is: " << gp;
  }
  return 0;
}

C Source Code

/*program 25*/
#include<stdio.h>

int main()
{
  float bp, hr, ca, gp;
  printf("Enter basic pay: ");
  scanf("%f", &bp);
  if(bp<1500)
    {
    hr = (70.0/100.0)*bp;
    ca = (20.0/100.0)*bp;
    gp = bp+hr+ca;
    printf("The gross pay is: %.2f", gp);
    }
  else
    {
    hr = (60.0/100.0)*bp;
    ca = (10.0/100.0)*bp;
    gp = bp+hr+ca;
    printf("The gross pay is: %.2f", gp);
    }
  return 0;
}

Output

Enter basic pay: 11000
The gross pay is: 18700

Design a site like this with WordPress.com
Get started