Menu

[Solved] Get Option One Work Display Data Code Completely Broke Working Ll Put Pictures Code Output Q37159137

Description Write a C++ program to calculate to analyze the data from the number of visitors to a national park in Maine. Req

stors to Acadia National Park nter 1 to display data nter 2 to display total number of recreation and non-recreational visito

I can get option one to work and display the data but all of myother code in completely broke and not working. I’ll put picturesof what my code outputs after my code

// Arcadia.cpp : This file contains the ‘main’ function. Programexecution begins and ends there.
//

#include “pch.h”
#include
#include
#include
#include
#include
#include

using namespace std;

void displayChart() {

   string months[12];
   int recVisitors[12], nRecVisitors[12],conLodging[12];
   int tentCampers[12], rvCampers[12], conCamping[12],bCampers[12], miscCampers[12], totOverNightStays[12];
   int i = 0;
   int sumReV = 0, sumNReV = 0, sumConLod = 0, sumTentC =0, sumRVC = 0, sumconC = 0, sumBC = 0, sumMC = 0, sumOS = 0;
   //read data from months and acadiaVisitors file intoarrays.
   ifstream inputFile(“C:AcadiaVisitors.txt”);
   ifstream monthFile(“C:Months.txt”);

   if (!inputFile || !monthFile)
       cout << “Failed to OpenFile”;

   while (inputFile >> recVisitors[i] &&(monthFile >> months[i])) //read data from monthsandacadiavisitors file into arrays.
   {
       inputFile >>nRecVisitors[i];
       inputFile >>conLodging[i];
       inputFile >>tentCampers[i];
       inputFile >>rvCampers[i];
       inputFile >>conCamping[i];
       inputFile >>bCampers[i];
       inputFile >>miscCampers[i];
       inputFile >>totOverNightStays[i];
       i++;
   }

   i = 0;
   cout << setw(14) << “Months” <<setw(22) << “Recreational Visitors” << setw(24)<< “Non Recreational Visitors” << setw(20) <<“Concession Lodging” << setw(12) << “TentCampers”
       << setw(12) << “RVCamper” << setw(20) << “Concession camping” <<setw(20) << “BackCountry Campers” << setw(14) <<“Misc Campers” << setw(25) << “Total Overnight Stays”<< endl;

   while (i != 12) {
       cout << setw(14) <<months[i] << setw(22) << recVisitors[i] <<setw(24) << nRecVisitors[i] << setw(20) <<conLodging[i] << setw(12) << tentCampers[i] <<setw(12) << rvCampers[i]
           <<setw(20) << conCamping[i] << setw(20) <<bCampers[i] << setw(14) << miscCampers[i] <<setw(25) << totOverNightStays[i];
       cout << endl;
       i++;
   }
   for (i = 0; i < 12; i++)
   {

       sumReV += recVisitors[i];
       sumNReV += nRecVisitors[i];
       sumConLod += conLodging[i];
       sumTentC += tentCampers[i];
       sumRVC += rvCampers[i];
       sumconC += conCamping[i];
       sumBC += bCampers[i];
       sumMC += miscCampers[i];
       sumOS +=totOverNightStays[i];
   }
   cout << setw(14) << “Total 2016” <<setw(22) << sumReV << setw(24) << sumNReV<< setw(20) << sumConLod << setw(12) <<sumTentC << setw(12) << sumRVC
       << setw(20) << sumconC<< setw(20) << sumBC << setw(14) << sumMC<< setw(25) << sumOS;
   cout << endl;
   cout << setw(14) << “Report Totals”<< setw(22) << sumReV << setw(24) <<sumNReV << setw(20) << sumConLod << setw(12)<< sumTentC << setw(12) << sumRVC
       << setw(20) << sumconC<< setw(20) << sumBC << setw(14) << sumMC<< setw(25) << sumOS;
   cout << endl;
   return;
}

void totalRecNonRecVisitors(int rec[], int nonRec[]) {
   int sumReV = 0, sumNReV = 0;
   for (int i = 0; i < 12; i++)
   {
       sumReV += rec[i];
       sumNReV += nonRec[i];
   }
   cout << “Total Recreational and Non RecrationalVisitors to the park ” << (sumNReV + sumReV) <<endl;
   return;
}

void tentRvCampers(int tentCampers[], int rvCampers[]) {

   int sumRV = 0, sumTent = 0;
   for (int i = 0; i < 12; i++)
   {
       sumRV += tentCampers[i];
       sumTent += rvCampers[i];
   }

   cout << “Total RV Campers to the Park: “<< sumRV << endl;
   cout << “Total Tent Campers to the Park: “<< sumTent << endl;
   return;
}

void recVisitorMonth(string months[], int recVisitors[], stringmonth) {

   month[0] = toupper(month[0]);
   for (int i = 0; i < 12; i++)
   {
       if (months[i].find(month, 0) !=std::string::npos)
       {
           cout <<“Recreational Visitors in month ” << month << ” were :” << recVisitors[i] << endl;
           break;
       }
   }
   return;

}

int main()
{
   string months[12];
   int recVisitors[12], nRecVisitors[12],conLodging[12];
   int tentCampers[12], rvCampers[12], conCamping[12],bCampers[12], miscCampers[12], totOverNightStays[12];
   int i = 0;

   //read data from months and acadiaVisitors fileinto arrays.
   ifstream inputFile(“AcadiaVisitors.txt”);
   ifstream monthFile(“Months.txt”);

   if (!inputFile || !monthFile)
       cout << “Failed to OpenFile”;

   while (inputFile >> recVisitors[i] &&(monthFile >> months[i])) //read data from monthsandacadiavisitors file into arrays.
   {
       inputFile >>nRecVisitors[i];
       inputFile >>conLodging[i];
       inputFile >>tentCampers[i];
       inputFile >>rvCampers[i];
       inputFile >>conCamping[i];
       inputFile >>bCampers[i];
       inputFile >>miscCampers[i];
       inputFile >>totOverNightStays[i];
       i++;
   }

   int opt = 0;

   while (opt != 5) {

       cout << “***********AcadiaNational Parl****************n”;
       cout << “1.Display the AcadiaVisitors Datan”;
       cout << “2.Recreational andnon-recreation visitors to the park.n”;
       cout << “3.Tent and RVcampers to the park.n”;
       cout << “4.Recreationalvisitors to the park for a month.n”;
       cout << “5. EXIT n”;
       cout << “Enter yourOption”;
       cin >> opt;
       cout << “nnn”;

       switch (opt) {
       case 1:
          displayChart();
           break;
       case 2:
          totalRecNonRecVisitors(recVisitors, nRecVisitors);
           break;
       case 3:
          tentRvCampers(tentCampers, rvCampers);
           break;
       case 4: {
           stringmonth;
           cout <<“Recreational visitors, for which Month ? “;
           cin >>month;
          recVisitorMonth(months, recVisitors, month);
           break;
       }
       default:
           cout <<“Invalid option Try again n”;
           break;
       }

       cout << “nnnn”;
   }

   return 0;
}

This is what that code above outputs for meEnter your Option1 Months Recreational VisitorsNon Recreational Visitors Concession LodgingTent Campers RV Camper Concession

The only option that seems to work is option 1 and that is justdisplaying the data, what is wrong with my code? The numbers arejust totally off, my guess it that its not reading the filecorrectly or putting it into an array correctly.

Here are the text files:

Loops.zip Local Disk (C) AcadiaVisitors.tt-Notepad File Edit Format View Help 17204 600 16530 600 28121 600 0 94199 600 21714Local Disk(C) File Edit Formet View Help anuary February March April May June July August September October November December

Description Write a C++ program to calculate to analyze the data from the number of visitors to a national park in Maine. Requirements 1. Read the data from the Months.txt and AcadiaVisitors.txt files. The text files are provided for you to download. The data was obtained from the National Park Service website. Design the program so the user enters a menu item and the following is displayed 2. Display the chart below Totals and display all recreational and non-recreation visitors to the park. Total and display the number of tent and RV campers. Prompt the user to enter a month and display the number of recreational visitors for that month. a. b. c. d. 3. 4. Each of the above should be separate functions. Design the program so the user can continuously enter a menu item and terminate the program when done. Acadia NP Beolmark this report htpsma nps Concession Tent RV Concession Backcountry Misc Overniaht Visitors Recreation Concession Campers Campers Camping Campers 17.204 600 28.121 94.199 217.147 45.410 695.854 735945 September 570,434 412 416 55.022 14,111 2016 Totals 3,303.393 600 0 885 168 10.521 1854 0 25.488 7,938 0 39.942 11,757 0 40.557 11,649 0 23.148 10,044 0 12270 3219 10 1,063 637 13.050 03 1,425 35,154 353 2966 55.018 381 2,250 55,197 984 35.042 0 291 15,780 7,500 7,500 7,500 7,500 7,500 6,000 600 617 249 47.100 0 152,811 46,629 977 1324 8.563 210.304 Report Totals 3,303,393 D 152811 4,829 1,324 8563 210,304 stors to Acadia National Park nter 1 to display data nter 2 to display total number of recreation and non-recreational visitors nter 3 to display total tent and RV campers by month nter 4 to display the number of recreational visitors for a certain montlh nter any other number to exit sitors to the Park by Month and Type: T RecT Non-Rec Con lodging TentR RV Con Camp BackCounty Misc Camp TOvernite 17284 16538 28121 94199 217147 445418 pril 1863 13050 35154 55018 55197 35842 15788 885 10521 168 1854 938 11757 11649 1e 637 38 uly 2966 2250 35945 570434 412416 55822 14111 40557 23148 12270 eptember ctober 617 219 291 ecenber nter 1 to display data nter 2 to display total number of recreation and non-recreational visitors nter 3 to display total tent and RV campers by month nter 4 to display the number of recreational visitors for a certain month nter any other number to exit he total number of recreational and non-recreational visitors: 3358493 nter 1 to display data nter 2 to display total number of recreation and non-recreational visitors nter 3 to display total tent and RV campers by month nter 4 to display the number of recreational visitors for a certain month nter any other number to exit We were unable to transcribe this imageLoops.zip Local Disk (C) AcadiaVisitors.tt-Notepad File Edit Format View Help 17204 600 16530 600 28121 600 0 94199 600 217147 7500 445410 75000 696854 7500 735945 7500 0 570434 7500 0 412416 6000 0 55822 600 14111 600 This PC Locl Disk (C) Name Date modified 2/11/2019 11:28 AM File folder 9/2/2018 7:36 PMFile folder 2/11/2019 11:42AM File folder 11/27/2018 11:54 File folder 4/11/2018 7:38 PM File folder 4/12/20194:41 PMFile folder 4/12/20194:41 PMFile folder /21/2019 12-41 AM File folder 1/19/2019 3:02 4/19/2019 2:16 PM File folder /21/2019 10-01 AM Text Document 4/21/2019 10-01 AM Text Document 3/23/2019 10.00 AM Text Document 63 SWINDOWS-BT Drivers ESD Intel PerfLogs Program Files 885 168 10521 1854 25488 7938 0 1063 13050 35154 38 303 1425 353 2966 55818 637 9942 11757 40557 11649 360 3812250 55197 23148 10044 617 249 984 35042 12270 3219 Program Files (x86) 291 15780 PM File folder Windows AcadiaVisitors.txt 1 KB 1 KB O KB 2 KB 2 KB 2 KB 2 KB 131 KB 8 KB quizgrades.tot ulog.HeadlightsCC AppCrash_4e75b79… 12/12/2018 1045. XML Document ulog HeadlightsCC AppCrash 4ee2d26.. 12/12/2018 10:50 XML Document ulog HeadlightsCC AppCrash 87adfad4… 12/12/2018 10:16.XML Document ulog HeadlightsCC AppCrash 317e1544.. 12/12/2018 10:19. XML Document wubildr wubildr.mbr 7/28/2018 11:44 PM 7/28/2018 11:40 PM File MBR File Local Disk(C) File Edit Formet View Help anuary February March April May June July August September October November December ↑ İ. ) This PC ) Local Disk (C:) Search Local Disk( 2/11/2019 11:28 AMFile folder 2/11/2019 11:42 AM File folder Program Files (05) 4/12/2019 441 PM Filefolder 1/21/2019 12:41 AM File folder 3/23/2019 1000AM Text Document ulog_HesdlightsCC AppCresh_75b79… 12/12/2018 1045XML Document ulog HeadightscC ApCrash_4e246 12/12/7218 10-50Ment ulag HeadightsCC AppCrash 8Tadfad. 12/12/2018 10:16XM Document ulog HeadlightsCCAppCrash 317e1544 12/122018 10:19XML Document 7/28/2018 11:40 PM MBR File Show transcribed image text Description Write a C++ program to calculate to analyze the data from the number of visitors to a national park in Maine. Requirements 1. Read the data from the Months.txt and AcadiaVisitors.txt files. The text files are provided for you to download. The data was obtained from the National Park Service website. Design the program so the user enters a menu item and the following is displayed 2. Display the chart below Totals and display all recreational and non-recreation visitors to the park. Total and display the number of tent and RV campers. Prompt the user to enter a month and display the number of recreational visitors for that month. a. b. c. d. 3. 4. Each of the above should be separate functions. Design the program so the user can continuously enter a menu item and terminate the program when done. Acadia NP Beolmark this report htpsma nps Concession Tent RV Concession Backcountry Misc Overniaht Visitors Recreation Concession Campers Campers Camping Campers 17.204 600 28.121 94.199 217.147 45.410 695.854 735945 September 570,434 412 416 55.022 14,111 2016 Totals 3,303.393 600 0 885 168 10.521 1854 0 25.488 7,938 0 39.942 11,757 0 40.557 11,649 0 23.148 10,044 0 12270 3219 10 1,063 637 13.050 03 1,425 35,154 353 2966 55.018 381 2,250 55,197 984 35.042 0 291 15,780 7,500 7,500 7,500 7,500 7,500 6,000 600 617 249 47.100 0 152,811 46,629 977 1324 8.563 210.304 Report Totals 3,303,393 D 152811 4,829 1,324 8563 210,304
stors to Acadia National Park nter 1 to display data nter 2 to display total number of recreation and non-recreational visitors nter 3 to display total tent and RV campers by month nter 4 to display the number of recreational visitors for a certain montlh nter any other number to exit sitors to the Park by Month and Type: T RecT Non-Rec Con lodging TentR RV Con Camp BackCounty Misc Camp TOvernite 17284 16538 28121 94199 217147 445418 pril 1863 13050 35154 55018 55197 35842 15788 885 10521 168 1854 938 11757 11649 1e 637 38 uly 2966 2250 35945 570434 412416 55822 14111 40557 23148 12270 eptember ctober 617 219 291 ecenber nter 1 to display data nter 2 to display total number of recreation and non-recreational visitors nter 3 to display total tent and RV campers by month nter 4 to display the number of recreational visitors for a certain month nter any other number to exit he total number of recreational and non-recreational visitors: 3358493 nter 1 to display data nter 2 to display total number of recreation and non-recreational visitors nter 3 to display total tent and RV campers by month nter 4 to display the number of recreational visitors for a certain month nter any other number to exit

Loops.zip Local Disk (C) AcadiaVisitors.tt-Notepad File Edit Format View Help 17204 600 16530 600 28121 600 0 94199 600 217147 7500 445410 75000 696854 7500 735945 7500 0 570434 7500 0 412416 6000 0 55822 600 14111 600 This PC Locl Disk (C) Name Date modified 2/11/2019 11:28 AM File folder 9/2/2018 7:36 PMFile folder 2/11/2019 11:42AM File folder 11/27/2018 11:54 File folder 4/11/2018 7:38 PM File folder 4/12/20194:41 PMFile folder 4/12/20194:41 PMFile folder /21/2019 12-41 AM File folder 1/19/2019 3:02 4/19/2019 2:16 PM File folder /21/2019 10-01 AM Text Document 4/21/2019 10-01 AM Text Document 3/23/2019 10.00 AM Text Document 63 SWINDOWS-BT Drivers ESD Intel PerfLogs Program Files 885 168 10521 1854 25488 7938 0 1063 13050 35154 38 303 1425 353 2966 55818 637 9942 11757 40557 11649 360 3812250 55197 23148 10044 617 249 984 35042 12270 3219 Program Files (x86) 291 15780 PM File folder Windows AcadiaVisitors.txt 1 KB 1 KB O KB 2 KB 2 KB 2 KB 2 KB 131 KB 8 KB quizgrades.tot ulog.HeadlightsCC AppCrash_4e75b79… 12/12/2018 1045. XML Document ulog HeadlightsCC AppCrash 4ee2d26.. 12/12/2018 10:50 XML Document ulog HeadlightsCC AppCrash 87adfad4… 12/12/2018 10:16.XML Document ulog HeadlightsCC AppCrash 317e1544.. 12/12/2018 10:19. XML Document wubildr wubildr.mbr 7/28/2018 11:44 PM 7/28/2018 11:40 PM File MBR File
Local Disk(C) File Edit Formet View Help anuary February March April May June July August September October November December ↑ İ. ) This PC ) Local Disk (C:) Search Local Disk( 2/11/2019 11:28 AMFile folder 2/11/2019 11:42 AM File folder Program Files (05) 4/12/2019 441 PM Filefolder 1/21/2019 12:41 AM File folder 3/23/2019 1000AM Text Document ulog_HesdlightsCC AppCresh_75b79… 12/12/2018 1045XML Document ulog HeadightscC ApCrash_4e246 12/12/7218 10-50Ment ulag HeadightsCC AppCrash 8Tadfad. 12/12/2018 10:16XM Document ulog HeadlightsCCAppCrash 317e1544 12/122018 10:19XML Document 7/28/2018 11:40 PM MBR File

Expert Answer


Answer to I can get option one to work and display the data but all of my other code in completely broke and not working. I’ll put… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *