CLOSE!
CLOSE THIS!
Started by DragonFyZex [1856798] on in Graveyard.
About this thread
Posts archived: 9 / 9 posts (100%) · the total is Torn's reply count + the opening post at the last fetch
Counted by TornLife from the archived posts.
- Archived posts
- 9
- Discussion span
- →
- People posting
- 7
- Likes on archived posts
- 0
- Authority score
- 18 / 100
- Historical score
- 23 / 100
- Story score
- 44 / 100
- Engagement score
- 46 / 100
Mentioned in this thread
CLOSE!
I'm sure there's plenty of tutorials on youtube mate.
I like how NO is winning. :D
Here:
#include
/*This is a comment. Go read "head first C++" or something.*/
int main(){
printf("Is this basic enough?");
return 0;
}
Dash: If you are going to do that, at least use proper C++..
Mauk [1494436]Dash: If you are going to do that, at least use proper C++..
I didn't think anyone would mind for a "hello world", but you're right, this is just C. You get a cookie. ;)
Mentions: Mauk [1494436]
Some basic C++
The getValidInput() is kinda neat. It catches errors that the library functions miss.
example: 123a56 will pass as a valid number, but only process 123.
Where getValidInput() will display an error.
/* Author: Rookie
INFO_1522
C++ Programming I
*/
//This program will except any number of user inputs and store the data in Vectors.
//Calculate and print the Gross pay after each entry.
//When finished entering data, program will print all the records including:
//Hours, Pay Rate, Gross Pay, and tax Withholdings.
#include
#include
#include
#include
#include
using namespace std;
using std::cout;
using std::endl;
int main() {
double varHoursWorked = 0;
float varPayRate = 0;
double varGrossPay = 0;
char continueYes;
double wrk1 = 0;
double wrk2 = 0;
double wrk3 = 0;
double wrk4 = 0;
int employeeNumber = 1;
double taxMe(double tax);
double getValidInput();
double Round(double round);
vector hoursWorked;
vector payRate;
vector grossPay;
vector withholding;
double vectorSize = 0;
do {
do {
cout cout varHoursWorked = getValidInput();
if (varHoursWorked 100){ // validate input
cout }
} while (varHoursWorked 100);
hoursWorked.push_back(varHoursWorked); // save the original good value in Vector hoursWorked
cout cin >> varPayRate;
payRate.push_back(varPayRate); // save the original value in Vector payRate
if (varHoursWorked > 60) {
wrk1 = (varHoursWorked - 60); // holds the difference over 60 hrs
wrk2 = (varHoursWorked - wrk1); // holds 60 hrs
wrk3 = (varPayRate * 2); // holds adjusted pay
wrk4 = (wrk1 * wrk3); // holds adjusted gross pay
varGrossPay = wrk4; // holds true gross pay
wrk2 = (wrk2 - 40); // holds 20 hrs
wrk3 = (varPayRate * 1.5); // holds adjusted pay
wrk4 = (wrk2 * wrk3); // holds adusted gross pay
varGrossPay = varGrossPay + wrk4; // holds true gross pay
varGrossPay = (40 * varPayRate) + varGrossPay;
cout grossPay.push_back(varGrossPay); // save value in Vector grossPay
cout
}// End IF
if (varHoursWorked 40) {
wrk1 = (varHoursWorked - 40); // holds the difference over 40 hrs
wrk2 = (varHoursWorked - wrk1); // holds 40 hrs
wrk3 = (varPayRate * 1.5); // holds adjusted pay
wrk4 = (wrk1 * wrk3); // holds adjusted gross pay
varGrossPay = wrk4; // holds true gross pay
varGrossPay = (40 * varPayRate) + varGrossPay;
cout grossPay.push_back(varGrossPay); // save value in Vector grossPay
cout
} // End IF
if (varHoursWorked varGrossPay = (varHoursWorked * varPayRate);
cout grossPay.push_back(varGrossPay); // save value in Vector grossPay
cout
} // End IF
cout cout cin >> continueYes;
employeeNumber = employeeNumber + 1;
} while (continueYes == 'y');
// withholding taxMe() Function call
vectorSize = hoursWorked.size(); // get the length of the Vector size
for (int i = 0; i wrk1 = grossPay;
wrk1 = Round(wrk1);
wrk2 = taxMe(wrk1);
wrk2 = Round(wrk2);
withholding.push_back(wrk2); // save value in Vector withholding
}
// Header for Output
cout cout cout cout setw(15) setw(15) setw(15) cout
// Print Data
vectorSize = hoursWorked.size();
for (int i = 0; i {
cout cout
cout cout setw(15) setw(15) setw(10) }
cout return 0;
} // End Main()
// ***** User Defined Functions *****
// Function taxMe()
double taxMe(double tax)
{
double difference,
taxable,
remaining,
tempHold;
if (tax > 500) {
difference = (tax - 500);
remaining = (tax - difference); // 500
taxable = difference * 22/100;
tempHold = taxable;
remaining = (remaining - 150); // 350
taxable = 150 * 18/100;
tempHold = tempHold + taxable;
remaining = (remaining - 150); // 200
taxable = 150 * 14/100;
tempHold = tempHold + taxable;
tempHold = 200 * 10/100 + tempHold;
return tempHold;
}
if (tax 350) {
difference = (500 - tax);
taxable = difference * 18/100;
tempHold = taxable;
tempHold = 150 * 14/100;
tempHold = (tempHold + taxable);
tempHold = 200 * 10/100 + tempHold;
return tempHold;
}
if (tax 200) {
difference = (tax - 200);
taxable = difference * 14/100;
tempHold = taxable;
tempHold = 200 * 10/100 + tempHold;
return tempHold;
}
if (tax tempHold = tax * 10/100;
return tempHold;
}
}
// Function Round()
double Round(double round)
{
double rnd;
rnd = round + .005;
rnd = rnd * 100;
rnd = int(rnd);
rnd = rnd / 100;
return rnd;
}
// Function getValidInput()
double getValidInput()
{
char string[8];
int len;
int ind = 0;
int ind2 = 0;
int amt = 0;
while (ind == 0)
{
if (ind2 == 1)
ind2 = 0;
cin >> string;
len = strlen(string);
for (int i = 0; i {
if (string else if (string > '9') ind2 = 1;
}
if (ind2 == 0) ind = 1;
else if (ind2 == 1)
cout cout
} // End While
for (int i = 0; i {
ind = string;
amt = 10 * amt + ind - 48;
}
return amt;
}
I believe that the people that said NO meant "we don't want to teach you anything" rather than if we can, yes I voted no.
Delyrium [904573]I believe that the people that said NO meant "we don't want to teach you anything" rather than if we can, yes I voted no.
wat
Mentions: Delyrium [904573]
As requested... [:sick:]