how to calculate the gross pay of an employee using C++

Subject
I this post I am discuss how to calculate the gross pay of an employee take salary as input for the user and calculate gross pay using formula.

Formula
“Grosspay=Salary=Allowance-Deduction”

This code is written to C++ initial declare four variable Salary , Allowance , Deduction , Grosspay and user enter the salary and calculate the gross pay.

Source Program:
#include "iostream"
using namespace std;
void main()
{
            float Salary , Allowance , Deduction , Grosspay;
            cout<<"The Monthly Salary is = ";
            cin>>Salary;
            cout<<"The Allowance is = ";
            Allowance=15*Salary/100;
            cout<<Allowance<<endl;
            cout<<"The Deduction is :";
            Deduction=10*Salary/100;
            cout<<Deduction<<endl;
            Grosspay=Salary+Allowance-Deduction;
            cout<<"The Total Grosspay is :"<<Grosspay<<endl;
}
Output:

The Output should like this.


The Monthly Salary is = 545
The Allowance is = 81.75
The Deduction is :54.5
The Total Grosspay is :572.25
--------------------------------
Press any key to continue . . .



Object:
In this Post I am discuss how to calculate a marks range using grade as inputs for users now student letter grade is calculated by following rules if and else condition this program is basic understanding of how id and else condition works.

Source Program:

This code is written to C++ initial declare one variable a and datatype is char and user enter the grade and program calculate the marks range.

#include "iostream"
using namespace std;
void main ()
{
      char a;
      cout<<"Grade:";
      cin>>a;
      if(a == 'a' || a == 'A')
      {
            cout<<"Marks >= 90 && Marks <= 100"<<endl;
      }
      else if ( a == 'b' || a == 'B' )
      {
            cout<<"Marks < 90 && Marks >= 80"<<endl;
      }
      else if(a == 'c' || a =='C' )
      {
      cout<<"Marks < 80 && Marks >= 70"<<endl;
      }
      else if( a == 'd' || a == 'D' )
      {
      cout<<"Marks < 70 && Marks >= 60"<<endl;
      }
      else if( a == 'e' || a == 'E' )
      {
      cout<<"Marks < 60 "<<endl;
      }
      else
      {
      cout<<"Invalid"<<endl;
      }
}
Output:
The Output should like this.

Grade:a
Marks >= 90 && Marks <= 100

Press any key to continue . . .

Popular posts from this blog

Find the total number of seconds hours and minutes as input

Week 11 System Testing and Deployment