I am an "old dude" who became frustrated with my current career and decided to go back to school to make a career change. I am in my second semester and in a C++ programming class. My question involves an assignment that has already been turned in for grading, and is not required as part of my assignment, but I am curious.
My code needs some work, but where I am curious is the end. How do I get the program to repeat after the system pause? I read about loops and whiles, but maybe I am missing something. After pressing "any key", my program terminates, but how would I get it to re-start from the beginning?
BTW, I used the "code tags", but apparently I used them wrong because it does not have the correct indentation. Please recall that I am an old dude trying to learn all of this stuff. I will eventually get. Please bear with me.
Code:
//Travis Bryant
//CPT-168-A01
//Calculate the Gross Pay Program
#include
<iostream>
using
namespace std;
int
main()
{
system(
"color f0");
cout<<
"\t\t\t***********************************"<<endl;
cout<<
"\t\t\t* Travis Bryant *"<<endl;
cout<<
"\t\t\t* CPT-168-A01 *"<<endl;
cout<<
"\t\t\t* Calculate the Gross Pay *"<<endl;
cout<<
"\t\t\t***********************************"<<endl;
double hrswrkd = 0.0, hrlyrat = 0.0, yrswrkd = 0.0,notpay = 0.0, otpay = 0.0, bnspay = 0.0, pay1 = 0.0, totpay = 0.0;
cout<<
"Please Enter Hours Worked: ";
cin>>hrswrkd;
cout<<
"Please Enter Hourly Pay Rate: ";
cin>>hrlyrat;
if (hrswrkd > 40)
notpay = hrlyrat * 40, otpay = (hrswrkd - 40) * 1.5 * hrlyrat, pay1 = otpay + notpay;
else
pay1 = hrswrkd * hrlyrat;
cout<<
"Gross Pay: $"<<pay1<<endl<<endl;
cout<<
"Please Enter Years of Service ";
cin>>yrswrkd;
if (yrswrkd >= 1 && yrswrkd <= 5)
bnspay = pay1 * .05;
else
if (yrswrkd >= 6 && yrswrkd <= 9)
bnspay = pay1 * .10;
else
if (yrswrkd == 10)
bnspay = pay1 * .15;
else
if (yrswrkd > 10)
bnspay = pay1 * .20;
//endif
//endif
//endif
//endif
cout<<
"Employee Longevity Bonus: $"<<bnspay<<endl<<endl;
totpay = pay1 + bnspay;
cout<<
"Total Employee Pay: $"<<totpay<<endl<<endl;
cout<<
"THANK YOU!!!"<<endl<<endl;
system(
"pause");
return 0;
}