Hello everyone, I am new to this world, at school right now and my code looks good, but the console isn't producing the appropriate output that I was looking for. Looking for help in figuring out why and how I can avoid this in the future.
Thanks in advance for all your help.
Brandon
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
inFile.open("inData.txt");
outFile.open("outData.txt");
string firstName, lastName, name, department;
double monthlySalary, monthlyBonus, amountBonus, totalIncome, taxes, taxRate, payCheck, distanceTraveled, travelingTime, averageSpeed, coffeeCost, coffeeSales;
int cupsSold;
outFile << fixed << showpoint << setprecision(2);
inFile >> firstName >> lastName >> department;
name = firstName + lastName;
outFile << "Name: " << name << ", Department: " << department << endl;
inFile >> monthlySalary >> monthlyBonus >> taxes;
amountBonus = (monthlySalary) * (monthlyBonus / 100);
totalIncome = monthlySalary + amountBonus;
taxRate = (totalIncome) * (taxes / 100);
payCheck = totalIncome - taxRate;
outFile << "Monthy Gross Salary: $" << monthlySalary << ", Monthly Bonus: " << monthlyBonus << "%" << ", Taxes: " << taxes << "%" << endl;
outFile << "Paycheck: $" << payCheck << endl;
inFile >> distanceTraveled >> travelingTime;
averageSpeed = distanceTraveled / travelingTime;
outFile << "Distance Traveled: " << distanceTraveled << " miles" << ", Traveling time: " << travelingTime << " hours" << endl;
outFile << "Average Speed: " << averageSpeed << " miles per hour" << endl;
inFile >> cupsSold >> coffeeCost;
coffeeSales = cupsSold * coffeeCost;
outFile << "Number of Coffee Cups Sold: " << cupsSold << ", Cost: $" << 1.50 << " per cup" << endl;
outFile << "Sales Amount: $" << coffeeSales << endl;
inFile.close();
outFile.close();
return 0;
}
What I have tried:
I have been going back and redoing everything several times without looking back at what I wrote before, in hopes that I have missed something, but I think I have met my level of expertise on it.
The output should show me:
Name: Giselle Robinson, Department: Accounting
Monthly Gross Salary: $5600.00, Monthly Bonus: 5.00%, Taxes: 30.00%
Paycheck: $4116.00
Distance Traveled: 450.00 miles, Traveling Time: 9.00 hours
Average Speed: 50.00 miles per hour
Number of Coffee Cups Sold: 75, Cost: $1.50 per cup
Sales Amount = $112.50
BUT I only get:
C:\Users\Brandon Ness\source\repos\CS265_BNess_Week2_Assignment\Week 2 Project\Release\Week 2 Project.exe (process 25488) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .