I m working on a project and have written code that determines how much money is spent in one day - the only problem is that I need to make it so the day 1 totals are outputted, then day 2 starts (with just the day 2 totals outputted), and then day 3 starts (with just the day 2 totals outputted) and then after all 3 days have ended, a total of totals from the 3 days is outputted. I ll paste my code in, but for some reason the formatting is messed up. Thank you!
void drillDay ()
{
int dayCounter = 1;
while (dayCounter > 0)
{
//Enlisted Soldiers, total number of Soldiers who attend
int privatesRankOneTotal = 0;
int privatesRankTwoTotal = 0;
int privatesRankThreeTotal = 0;
int specialistsCorporalsTotal = 0;
int sergeantsTotal = 0;
int staffSergeantsTotal = 0;
int pltSergeantsTotal = 0;
int masterSergeantsTotal = 0;
//Warrant Officers, total number of Warrant Officers who attend
int chiefWarrantRankOneTotal = 0;
int chiefWarrantRankTwoTotal = 0;
int chiefWarrantRankThreeTotal = 0;
//Officers, total number of officers who attend
int ltRankTwoTotal = 0;
int ltRankOneTotal = 0;
int captainsTotal = 0;
//How much each soldier is paid per day, based on rank.
double pvtOnePay = 99.40;
double pvtTwoPay = 111.42;
double pfcPay = 117.16;
double SpcCplPay = 136.42;
double sgtPay = 165.84;
double ssgPay = 229.12;
double sfcPay = 239.32;
double msgPay = 309.44;
double cwoOnePay = 233.40;
double cwoTwoPay = 274.92;
double cwoThreePay = 336.04;
double ltTwoPay = 188.56;
double ltOnePay = 294.96;
double cptPay = 335.40;
cout<<endl<<"Enter amount of enlisted soldiers:"<<endl<<endl;
cout<<"How many Privates (E-1) / (PVT) are attending drill today? "<<endl;
cin>>privatesRankOneTotal;
cout<<"How many Privates (E-2) / (PV2) are attending drill today? "<<endl;
cin>>privatesRankTwoTotal;
cout<<"How many Privates (E-3) / (PFC) are attending drill today? "<<endl;
cin>>privatesRankThreeTotal;
cout<<"How many Specialists / Corporals (E-4) / (SPC / CPL) are attending drill today? ";
cin>>specialistsCorporalsTotal;
cout<<"How many Sergeants (E-5) / (SGT) are attending drill today? "<<endl;
cin>>sergeantsTotal;
cout<<"How many Staff Sergeants (E-6) / (SSG) are attending drill today? "<<endl;
cin>>staffSergeantsTotal;
cout<<"How many Platoon Sergeants (E-7) / (SFC) are attending drill today? "<<endl;
cin>>pltSergeantsTotal;
cout<<"How many soldiers with the paygrade of (E-8) are attending drill today? "<<endl;
cin>>masterSergeantsTotal;
cout<<endl<<endl<<endl;
cout<<"Enter amount of Warrant Officers:"<<endl<<endl;
cout<<"How many Warrant Officers (W-1) / (WO1) are attending drill today? "<<endl;
cin>>chiefWarrantRankOneTotal;
cout<<"How many Warrant Officers (W-2) / (CW2) are attending drill today? "<<endl;
cin>>chiefWarrantRankTwoTotal;
cout<<"How many Warrant Officers (W-3) / (CW3) are attending drill today? "<<endl;
cin>>chiefWarrantRankThreeTotal;
cout<<endl<<endl<<endl;
cout<<"Enter amount of Officers:"<<endl<<endl;
cout<<"How many 2nd Lieutenants (O-1) / (2LT) are attending drill today? "<<endl;
cin>>ltRankOneTotal;
cout<<"How many 1st Lieutenants (O-2) / (1LT) are attending drill today? "<<endl;
cin>>ltRankTwoTotal;
cout<<"How many Officers with paygrade (O-3) / Rank (CPT) are attending drill today? "<<endl;
cin>>captainsTotal;
cout<<endl<<endl<<endl;
int totalEnlistedSoldiers = privatesRankOneTotal + privatesRankTwoTotal + privatesRankThreeTotal + specialistsCorporalsTotal + sergeantsTotal + staffSergeantsTotal + pltSergeantsTotal + masterSergeantsTotal;
cout<<"Total enlisted soldiers at drill today: "<<totalEnlistedSoldiers<<endl<<endl;
int totalWarrantOfficers = chiefWarrantRankOneTotal + chiefWarrantRankTwoTotal + chiefWarrantRankThreeTotal;
cout<<"Total Warrant Officers at drill today: "<<totalWarrantOfficers<<endl<<endl;
int totalOfficers = ltRankOneTotal + ltRankTwoTotal + captainsTotal;
cout<<"Total Officers at drill today: "<<totalOfficers<<endl<<endl;
int totalSoldiers = totalEnlistedSoldiers + totalWarrantOfficers + totalOfficers;
cout<<"Total soldiers (Enlisted, Warrant Officers, and Officers) at drill today: "<<totalSoldiers<<endl;
double privateOneTotalPay = privatesRankOneTotal*pvtOnePay;
double privateTwoTotalPay = privatesRankTwoTotal*pvtTwoPay;
double privateThreeTotalPay = privatesRankThreeTotal*pfcPay;
double spcCplTotalPay = specialistsCorporalsTotal*SpcCplPay;
double sgtTotalPay = sergeantsTotal*sgtPay;
double ssgTotalPay = staffSergeantsTotal*ssgPay;
double sfcTotalPay = pltSergeantsTotal*sfcPay;
double msgTotalPay = masterSergeantsTotal*msgPay;
double cwoOneTotalPay = chiefWarrantRankOneTotal*cwoOnePay;
double cwoTwoTotalPay = chiefWarrantRankTwoTotal*cwoTwoPay;
double cwoThreeTotalPay = chiefWarrantRankThreeTotal*cwoThreePay;
double ltOneTotalPay = ltRankTwoTotal*ltTwoPay;
double ltTwoTotalPay = ltRankOneTotal*ltOnePay;
double cptTotalPay = captainsTotal*cptPay;
double totalSoldiersDrillPay = privateOneTotalPay + privateTwoTotalPay + privateThreeTotalPay + spcCplTotalPay + sgtTotalPay + ssgTotalPay + sfcTotalPay + msgTotalPay + cwoOnePay + cwoTwoPay + cwoThreePay + ltOnePay + ltTwoPay + cptPay;
cout<<endl<<endl<<endl;
double costOfLunch = 14.99;
int soldiersProvidedLunch = 0;
int loopCounter = 1;
cout<<"How many soldiers were provided lunch today?"<<endl;
cin>>soldiersProvidedLunch;
cout<<endl;
double totalLunchCost = soldiersProvidedLunch*costOfLunch;
while (loopCounter == 1)
{
if (soldiersProvidedLunch <= totalSoldiers)
{
cout<<endl<<soldiersProvidedLunch<<" were provided lunch, the total cost of lunch today will be $"<<setiosflags(ios::fixed) << setprecision(2)<<totalLunchCost;
loopCounter --;
iii
else
{
cout<<totalSoldiers<<" soldiers were at drill today, there cannot be more."<<endl<<endl;
cout<<"Enter the number of soldiers that were provided lunch today."<<endl;
cin>>soldiersProvidedLunch;
iii
iii
cout<<endl<<endl<<endl;
double gasPrice = 3.87;
double gallonsPumped = 0;
cout<<"How many gallons of gasoline were purchased today:"<<endl;
cin>>gallonsPumped;
double finalGasPrice = gasPrice*gallonsPumped;
cout<<endl;
if (gallonsPumped >= 1)
{
cout<<endl<<"The total cost for gasoline today was $"<<setiosflags(ios::fixed) << setprecision(2) << finalGasPrice<<"."<<endl;
iii
else
{
cout<<"No money spent on gasoline today.";
iii
double dayDrillCost = finalGasPrice+totalLunchCost+totalSoldiersDrillPay;
cout<<endl<<endl<<endl<<"Totals for today: "<<endl<<"**************************************"<<endl;
cout<<"Total pay for soldiers present: $"<<setiosflags(ios::fixed) << setprecision(2)<<totalSoldiersDrillPay<<endl;
cout<<"Total amount of money spent on lunch: $"<<setiosflags(ios::fixed) << setprecision(2)<<totalLunchCost<<endl;
cout<<"Total amount of money spent on gas: $"<<setiosflags(ios::fixed) << setprecision(2)<<finalGasPrice<<endl<<"**************************************"<<endl;
cout<<"Cost of drill today: $"<<setiosflags(ios::fixed) << setprecision(2)<<dayDrillCost<<endl;
dayCounter --;
iii
cout<<"Drill completed";
iii