Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <array>
  4. #include <string>
  5. #include <fstream>
  6.  
  7. using namespace std;
  8.  
  9. ifstream inFile;
  10. ofstream outFile;
  11. const int fileSize = 50;
  12. bool cont = true;
  13. char option;
  14. int counter;
  15.  
  16. struct Household {
  17. string id;
  18. int income;
  19. int members;
  20. }household[fileSize];
  21.  
  22. int main() {
  23.  
  24.  
  25.  
  26. inFile.open("C:\\Users\\jjooe\\Desktop\\Test Data File for Lab 8A.txt");
  27. if (!inFile) {
  28. cout << "Error. Could not open file." << endl;
  29. system("pause");
  30. return 1;
  31. }
  32.  
  33. for (int i = 0; i < fileSize; i++) {
  34. inFile >> household[i].id;
  35. inFile >> household[i].income;
  36. inFile >> household[i].members;
  37. }
  38.  
  39.  
  40. while (cont == true) {
  41.  
  42. cout << "Enter a capital letter A-E to choose the option you want." << endl << endl;
  43. cout << "A. Display all of the household data." << endl;
  44. cout << "B. Dispaly the average household income and list the identification codes and income of each household whose income is greater than the average." << endl;
  45. cout << "C. Display the percentage of households having an income below the poverty level." << endl;
  46. cout << "D. Display all of the input data sorted by household income." << endl;
  47. cout << "E. Display the median household income." << endl;
  48.  
  49. cin >> option;
  50. if (option == 'A') {
  51.  
  52. }
  53.  
  54.  
  55.  
  56. }
  57.  
  58. }
  59.  
  60. void getData(Household input[], int& counter) {
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement