Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Chapter 3.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <stdlib.h>
- #include <cmath>
- #include <fstream>
- #include <iomanip>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- ifstream inFile;
- ofstream outFile;
- double sal1, sal2, sal3; // variable to read the 3 Salaries
- double pr1, pr2, pr3; // variables to read the 3 pay rates
- string fn1, fn2, fn3; // variables for first name
- string ln1, ln2, ln3; // variables for last name
- double inc1, inc2, inc3; // variables to store inc after calculated
- double rise1, rise2, rise3; // variables to store the percent
- double news1, news2, news3; // the new yearly salary
- inFile.open("Ch3_Ex8Data.txt"); //gets input from the file Ch3_Ex8Data.txt
- outFile.open("ch3_Ex8Output.dat"); //opens the output file Ch3_ex80Output.dat
- cout << "Processing data from file.." << endl << endl;
- inFile >> fn1 >> ln1 >> sal1 >> pr1;
- cout << ln1 << " " << fn1 << "\t\tSalary: " << sal1 << "\t\tPayrate Increase: " << pr1 << endl; // Displays the first person's information
- inFile >> fn2 >> ln2 >> sal2 >> pr2;
- cout << ln2 << " " << fn2 << "\t\tSalary: " << sal2 << "\t\tPayrate Increase: " << pr2 << endl; // Displays the second person's information
- inFile >> fn3 >> ln3 >> sal3 >> pr3;
- cout << ln3 << " " << fn3 << "\t\tSalary: " << sal3 << "\t\tPayrate Increase: " << pr3 << endl; // Displays the third person's information
- // first person
- rise1 = (pr1/100)*sal1;
- news1 = rise1+sal1;
- outFile << "Persons name: " << ln1 << " " << fn1 << endl << "Salary: " << sal1 << endl << "Increase: " << pr1 << endl << "Rise: " << rise1 << endl << "New Salary: " << news1 << endl << endl;
- // second person
- rise2 = (pr2/100)*sal2;
- news2 = rise2+sal2;
- outFile << "Persons name: " << ln2 << " " << fn2 << endl << "Salary: " << sal2 << endl << "Increase: " << pr2 << endl << "Rise: " << rise2 << endl << "New Salary: " << news2 << endl << endl;
- // third person
- rise3 = (pr3/100)*sal3;
- news3 = rise3+sal3;
- outFile << "Persons name: " << ln3 << " " << fn3 << endl << "Salary: " << sal3 << endl << "Increase: " << pr3 << endl << "Rise: " << rise3 << endl << "New Salary: " << news3 << endl << endl;
- inFile.close();
- outFile.close();
- system("pause");
- return 0;
- }
Add Comment
Please, Sign In to add comment