Chapter 2 – Q #6: Annual Pay – Tony Gaddis – Starting Out With C++

 Chapter 2 – Q #6: Annual Pay – Tony Gaddis – Starting Out With C++

Annual Pay


Problem:-

Suppose an employee gets paid every two weeks and earns $1700.00 each pay period. In a year the employee gets paid 26 times. Write a program that de nes the following variables:

 payAmount:   This variable will hold the amount of pay the employee earns each pay period. Initialize the variable with 1700.0.
 payPeriods: This variable will hold the number of pay periods in a year. Initialize the variable with 26
annualPay:   This variable will hold the employee s total annual pay, which will be calculated.

The program should calculate the employee s total annual pay by multiplying the employee s pay amount by the number of pay periods in a year, and store the result in the annualPay variable. Display the total annual pay on the screen

Solution:-

#include <iostream>

using namespace std;

int main()

{

      double payAmmount = 1700.0;

      double payPeriods = 26.0;

      double annualPay = payAmmount * payPeriods;

      cout << "Total Annual Pay is  " << annualPay << endl;

      return 0;

}

This is the solution of this question

Explanation of this Solution

1.     I declare payAmmount variable and initialize given value.

2.     I declare payPeriods variable and add initialize given value.

3.     Then, I declare annualPay variable and calculate the pay.

4.     In last, display output on the screen.

5.     Return 0 to the main function.


Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File


Post a Comment

0 Comments