Guest User

Untitled

a guest
Jun 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. // Chapter 3.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7. #include <stdlib.h>
  8. #include <cmath>
  9. #include <fstream>
  10. #include <iomanip>
  11. using namespace std;
  12.  
  13.  
  14. int _tmain(int argc, _TCHAR* argv[])
  15. {
  16.  
  17. ifstream inFile;
  18. ofstream outFile;
  19.  
  20. double sal1, sal2, sal3; // variable to read the 3 Salaries
  21. double pr1, pr2, pr3; // variables to read the 3 pay rates
  22. string fn1, fn2, fn3; // variables for first name
  23. string ln1, ln2, ln3; // variables for last name
  24.  
  25. double inc1, inc2, inc3; // variables to store inc after calculated
  26. double rise1, rise2, rise3; // variables to store the percent
  27. double news1, news2, news3; // the new yearly salary
  28.  
  29. inFile.open("Ch3_Ex8Data.txt"); //gets input from the file Ch3_Ex8Data.txt
  30. outFile.open("ch3_Ex8Output.dat"); //opens the output file Ch3_ex80Output.dat
  31.  
  32. cout << "Processing data from file.." << endl << endl;
  33.  
  34. inFile >> fn1 >> ln1 >> sal1 >> pr1;
  35. cout << ln1 << " " << fn1 << "\t\tSalary: " << sal1 << "\t\tPayrate Increase: " << pr1 << endl; // Displays the first person's information
  36.  
  37. inFile >> fn2 >> ln2 >> sal2 >> pr2;
  38. cout << ln2 << " " << fn2 << "\t\tSalary: " << sal2 << "\t\tPayrate Increase: " << pr2 << endl; // Displays the second person's information
  39.  
  40. inFile >> fn3 >> ln3 >> sal3 >> pr3;
  41. cout << ln3 << " " << fn3 << "\t\tSalary: " << sal3 << "\t\tPayrate Increase: " << pr3 << endl; // Displays the third person's information
  42. // first person
  43. rise1 = (pr1/100)*sal1;
  44. news1 = rise1+sal1;
  45. outFile << "Persons name: " << ln1 << " " << fn1 << endl << "Salary: " << sal1 << endl << "Increase: " << pr1 << endl << "Rise: " << rise1 << endl << "New Salary: " << news1 << endl << endl;
  46. // second person
  47. rise2 = (pr2/100)*sal2;
  48. news2 = rise2+sal2;
  49. outFile << "Persons name: " << ln2 << " " << fn2 << endl << "Salary: " << sal2 << endl << "Increase: " << pr2 << endl << "Rise: " << rise2 << endl << "New Salary: " << news2 << endl << endl;
  50. // third person
  51. rise3 = (pr3/100)*sal3;
  52. news3 = rise3+sal3;
  53. outFile << "Persons name: " << ln3 << " " << fn3 << endl << "Salary: " << sal3 << endl << "Increase: " << pr3 << endl << "Rise: " << rise3 << endl << "New Salary: " << news3 << endl << endl;
  54.  
  55.  
  56.  
  57.  
  58. inFile.close();
  59. outFile.close();
  60.  
  61. system("pause");
  62. return 0;
  63. }
Add Comment
Please, Sign In to add comment