#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
ifstream inData;
ofstream outData;
//the program will read data from indata.txt and output to outData.txt
inData.open("inData.txt");
outData.open("outData.txt");
// code to mannipulate data below
// line 1 input and output
string firstname, lastname, depart;
inData >> firstname >> lastname >> depart;
outData << "Name: " << firstname << " " << lastname << ", Department: " << depart << endl;
// line 2 input and output
double grossSalary, bonus, taxes;
inData >> grossSalary >> bonus >> taxes;
outData << fixed << setprecision(2);
outData << "Monthly Gross Salary: $" << grossSalary << ", Monthly Bonus "<< bonus << "%, Taxes: " << taxes << "%" << endl;
// paycheck calculations and output
double paycheck;
paycheck = grossSalary + (grossSalary * bonus/ 100) - (grossSalary * taxes/ 100);
outData << "Paycheck: $" << paycheck << endl;
//line 3 input and output
double distance, time, speed;
inData >> distance >> time;
//calculations for average speed
speed = distance / time;
outData << "Distance Traveled: " << distance << " miles, Traveling Time: "<< time << " hours " << speed << " miles per hour" << endl;
// line 4 input and output
int cupsSold;
double cupCost, sales;
inData >> cupsSold >> cupCost;
//calculations for sales
sales = cupsSold * cupCost;
outData << "Number of Coffee Cups Sold: " << cupsSold << ", Cost: $" << cupCost << endl;
outData << "Sales Amount= $" << sales << endl;
// closing both files
inData.close();
outData.close();
return 0;
}
Name: Maria Logan, Department: Sales
Monthly Gross Salary: $100000.00, Monthly Bonus 5.00%, Taxes: 2.50%
Paycheck: $102500.00
Distance Traveled: 7.50 miles, Traveling Time: 1.50 hours 5.00 miles per hour
Number of Coffee Cups Sold: 100, Cost: $2.50
Sales Amount= $250.00
Maria Logan Sales
100000 5 2.5
7.5 1.5
100 2.50