//VS8_multiple_if_examples_ex1.cpp
//Using a combination of the 'IF' construction
/* 'if' demo with relational and combinational operators */
// file name pound_example.cpp
// uses a statement with a pound sign
#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include <conio.h>
#include <stdio.h>
using namespace std;
unsigned char POUND_SIGN = 156;
void main()
{
float gross_pay,net_pay,tax,rate_of_pay;
int hours;
rate_of_pay=5.65;
tax = 40; // random value for tax to be paid. Change or ask user to enter it as they entered their hours.
cout<<"How many hours did you work? \n";
cin>>hours;
if (hours<40)
{
// Calculate gross pay. Assumed to be per week.
gross_pay = hours * rate_of_pay;
// Calculate net pay. Assuming tax is already calculated somehow and is in the form of "tax paid per week".
net_pay = gross_pay - tax;
cout << "Net Pay: " << net_pay;
}
if ((hours>40)&&(hours<=50))
{
// Calculate gross pay. Assumed to be per week.
gross_pay = hours * rate_of_pay;
// Calculate net pay. Assuming tax is already calculated somehow and is in the form of "tax paid per week".
net_pay = gross_pay - tax;
cout << "Net Pay: " << net_pay;
}
if (hours>50)
{
// Calculate gross pay. Assumed to be per week.
gross_pay = hours * rate_of_pay;
// Calculate net pay. Assuming tax is already calculated somehow and is in the form of "tax paid per week".
net_pay = gross_pay - tax;
cout << "Net Pay: " << net_pay;
}
//format output
cout << setprecision(2);
cout.setf(ios::showpoint);
cout.setf(ios::fixed);
// output you results here
if ((hours>40)&&(hours<=50))
{
cout << "We have printed non-formated output above.";
}
cout << "We have printed non-formated output above.";
system("pause");
return;
}
Last reply 1 week ago
Hello .. I am looking for computer science program BSc/BEng 2024 entryLast reply 3 weeks ago
What A-Levels should i do if i wanna do a Bsc in Computer ScienceLast reply 1 month ago
Correlation between performance in UKMT and performance in TMUA/STEP?Last reply 1 month ago
Do top universities allow just 3 A levels including Further Maths?Last reply 1 week ago
Hello .. I am looking for computer science program BSc/BEng 2024 entryLast reply 3 weeks ago
What A-Levels should i do if i wanna do a Bsc in Computer ScienceLast reply 1 month ago
Correlation between performance in UKMT and performance in TMUA/STEP?Last reply 1 month ago
Do top universities allow just 3 A levels including Further Maths?