Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What is the problem with my C++ code till this point. How to fix them. (functions.cpp main.cpp header.hpp) functions.cpp #include header.hpp int loadFlights(flightInfo infos[listSize],flightInfo &info)

What is the problem with my C++ code till this point. How to fix them. (functions.cpp main.cpp header.hpp)

functions.cpp

#include "header.hpp"

int loadFlights(flightInfo infos[listSize],flightInfo &info) { int SIZE = 0; ifstream file; cout << "What is the name of the flight data file? "; cin.getline(fileName,SIZE); file.open(fileName); while (!file.is_open()) { cout << "File doesn't exist, please try again: "; cin.getline(fileName,SIZE); } while(true) { file.getline(info.airline,SIZE,','); file >> info.flightNum; cin.ignore(); file >> info.departMonth; cin.ignore(); file >> info.departDay; cin.ignore(); file >> info.departTime; cin.ignore(); file >> info.arriveMonth; cin.ignore(); file >> info.arriveDay; cin.ignore(); file >> info.arriveTime; cin.ignore(); file.getline(info.departAirport,SIZE,','); file.getline(info.arriveAirport,SIZE,','); } } void addFlight(flightInfo &info) { cout << "What is the name of the ariline? "; cin.getline(info.airline,SIZE); cout << "What is the flight number? "; cin >> info.flightNum; } template void dataRow(A airline, B flightNum, C departMonth, D departDay, E departTime, F arriveMonth, G arriveDay, H arriveTime, I departAirport, J arriveAirport) { cout << left << setw(15) << airline << setw(5) << flightNum << setw(10) << departMonth << "/" << departDay << " at " << departTime << setw(10) << arriveMonth << "/" << arriveDay << " at " << arriveTime << setw(10) << departAirport << setw(10) << arriveAirport << ' '; } bool searchFlights(flightInfo infos[], int count) { char airline[SIZE]; cout << "For what flight would you like to search? "; cin.getline(airline,SIZE); dataRow("Airline","Flight#","Departure"," "," ","Arrival"," "," ","From","To"); for (int i =0; i < count; i++) if (strcmp(airline, infos[i].airline)==0) dataRow(infos[i].airline, infos[i].departMonth, infos[i].departDay, infos[i].arriveMonth, infos[i].arriveDay, infos[i].arriveTime,infos[i].departAirport, infos[i].arriveAirport)

void listFlights(flightInfo infos[],int count){ dataRow("Airline","Flight#","Departure"," "," ","Arroval"," "," ","From","To"); for (int i = 0; i

______________________________

main.cpp

#include "header.hpp"

int main() { flightInfo infos[listSize];

cout << "Welcome to the program." << endl; loadFlights(flightInfo infos[listSize],flightInfo &info); cout << "What would you like to do: (l)ist all, (s)earch, (a)dd an exercise, or (q)uit?: " << endl; cin.getline(choice,SIZE); if (choice == 'l') { listFlights(infos,SIZE); } else if (choice == 's') { searchFlights(infos,SIZE); } return 0; }

__________________________________________________

header.hpp

#ifndef __HEADER__ #define __HEADER__

#include #include #include #include

using namespace std;

const int SIZE = 128; const int listSize = 100; char fileName[SIZE]; int flightCount = 0;

//Declaring Prototypes int loadFlights(flightInfo infos[listSize], flightInfo &info); void addFlight(flightInfo &info); void dataRow(A,B,C,D,E,F,G,H,I,J); bool searchFlights(flightInfo infos[], int count); void listFlights(flightInfo infos[], int count);

struct flightInfo { char airline[SIZE]; int flightNum; int departMonth; int departDay; double departTime; int arriveMonth; int arriveDay; double arriveTime; char departAirport[SIZE]; char arriveAirport[SIZE]; ; };

class flightTrack { flightInfo data[SIZE]; int countIndex; char FileName[SIZE];

public: int loadFlights(); void addFlight(); bool srearchFlights(); void listFlights(); }; #endif

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 2 Lncs 13427

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124251, 978-3031124259

More Books

Students also viewed these Databases questions

Question

Are robots going to displace all workers? Explain your answer.

Answered: 1 week ago