Answer:
C++ program: -
//header files
#include <iostream>
//namespace for using input and output stream
using namespace std;
//main function
int main()
{
//declaring the variables
float wg,hrs,pt,np;
//prompt the user to enter the hourly wage
cout<<"Please enter the hourly wage: ";
//storing the value
cin>>wg;
//prompt the user to enter the working hours
cout<<"Please enter the hours worked: ";
//storing the values
cin>>hrs;
//prompt the user to enter to enter the percentage
cout<<"Please enter the withholding percentage: ";
//storing the value
cin>>pt;
//calculating the next week pay
np= (hrs*wg*7)- (hrs*wg*7*pt/100);
//displaying the next week pay
cout<<"Net weekly pay: "<<np;
//return statement
return 0;
}
Explanation:
In the above program, the variable used are given below: -
float wg,hrs,pt,np;
wg:- To store the hourly wage
hrs:- To store the working hours
pt:- To store the percentage
np:- To store the next week payment
The input and the output streams that are used to input and storing the values are cin and cout.
To calculate the next week payment below formula is used:-
np= (hrs*wg*7)- (hrs*wg*7*pt/100);
Output :-
Please enter the hourly wage: 100
Please enter the hours worked: 8
Please enter the withholding percentage: 5
Net weekly pay: 5320