CSCI1410 – PA3 Part I (10 Points): For this part of the assignment you will be create an outline in comments/psuedocode for the programming assignment below. Place everything in a single file, but use...

1 answer below »
I need help with C++ programming homework please.


CSCI1410 – PA3 Part I (10 Points): For this part of the assignment you will be create an outline in comments/psuedocode for the programming assignment below. Place everything in a single file, but use the following comments to show how you will separate the files when you submit Part II: //your name //Dealer.h //Dealer.cpp //functions.cpp //main.cpp There will be two classes Dealer and Car as explained below. You should define the two classes in your Dealer.h section. Then you should provide pseudocode under Dealer.cpp section to describe the functions of each class. Describe in pseudocode the main menu functions under the functions.cpp section. The main.cpp section will just consist of declaring a vector of type Dealer (if you don’t know how to do this yet, just place comments in plain English). Then you will have a menu that calls the functions. Part II: ( 40 Points) For this programming assignment, you will be creating a program to manage cars in a dealership. This will again be a menu driven system. You will make a vector of Dealers (there can be zero to many dealers). Each dealer can have zero to many cars on the lot, represented not by a vector, but by a dynamic array. The following is your menu: 1. Read Dealers and Cars from file 2. Display Dealers 3. Choose a Dealer Number, Display Cars 4. Choose a Dealer Number, Add Car 5. Choose a Dealer Number, List Cars and Modify a Car (EXTRA CREDIT) 6. Choose a Dealer, Sort cars by VIN (EXTRA CREDIT) 7. Write Dealers and Cars to file. 8. Exit Your program will be object oriented (using classes, not structs) with the following classes defined in Dealer.h: Dealer.h #ifndef _DEALER #define _DEALER class Dealer { private: string dealerName; int dealerNumber; int numberOfCars; Car *carArrayPtr; //This is the pointer to dynamic array of Car, you can also declare this to //be public public: Dealer ( ) Dealer ( string _dealerName, int _dealerNumber); void setDealerName (string _dealerName); void setDealerNumber (string _dealerNumber); void setNumberOfCars ( int _numberOfCars); void setCarArray(Car * carArrayPtr); //You don’t need this if the attribute is public string getDealerName ( ); int getDealerNumber ( ); int getNumberOfCars( ); Car* getCarArray(); //You don’t need this if the array pointer is public + friend ostream & operator < (ostream="" &out,="" dealer="" _dealer);="" print="" the="" dealer="" name="" and="" number="" and="" blank="" line="" for="" a="" specific="" dealer.="" };="" class="" car="" {="" private:="" string="" vin;="" string="" make;="" string="" model;="" int="" year;="" double="" price;="" public:="" car(="" );="" car(string="" _vin,="" string="" _make,="" string="" model,="" int="" year,="" double="" price);="" +="" getvin(="" ):string="" +="" getmake(="" ):string="" +="" getmodel(="" ):string="" +="" getyear(="" ):int="" +="" getprice(="" ):double="" +="" setvin(_vin:string):void="" +="" setmake(_make:string):void="" +="" setmodel(_model:string):void="" +="" setyear(_year:int):void="" +="" setprice(_price:double):void="" +="" friend="" operator="">< (out:="" ostream="" &,="" car:="" _car):ostream="" &="" print="" the="" vin,="" make,="" model,="" year,="" price="" and="" blank="" line="" for="" a="" specific="" car.="" #endif="" you="" will="" have="" four="" files="" for="" your="" program="" (use="" these="" file="" names!):="" main.cpp,="" functions.h,="" dealer.h,="" dealer.cpp.="" place="" into="" a="" file="" folder="" named="" lastnamepa3,="" then="" zip="" the="" content="" and="" hand="" in="" a="" zip="" file="" to="" canvas="" ·="" main.cpp:="" this="" will="" be="" your="" driver="" file.="" ·="" functions.h:="" this="" will="" contain="" your="" functions="" for="" each="" of="" the="" menu="" items.="" ·="" dealer.h:="" this="" will="" contain="" the="" class="" declarations="" for="" car="" and="" dealer="" including="" the="" operator=""><. ·="" dealer.cpp:="" this="" will="" contain="" the="" class="" implementations="" for="" car="" and="" dealer.="" remember,="" you="" do="" not="" #include="" “dealer.cpp”,="" just="" #include="" “functions.h”="" and="" #include="" “dealer.h”="" in="" main.cpp.="" you="" will="" be="" storing="" your="" dealer="" objects="" in="" a="" vector.="" in="" the="" main="" function,="" you="" will="" create="" a="" vector="" of="" dealers.="" when="" the="" menu="" is="" called,="" you="" will="" have="" to="" check="" your="" vector="" and="" ensure="" that="" it="" is="" not="" empty="" (size="=" 0)="" before="" referring="" to="" the="" index="" number="" of="" the="" vector.="" your="" dealer="" vector="" points="" to="" a="" dynamic="" array="" of="" cars="" (remember="" dynamic="" arrays="" use="" the="" keyword="" new).="" when="" you="" access="" the="" cars="" class="" you="" should="" verify="" that="" it="" is="" not="" set="" to="" nullptr="" before="" accessing="" it.="" you="" may="" not="" use="" any="" global="" variables,="" so="" must="" pass="" vectors="" and="" arrays="" into="" parameters.="" if="" you="" want="" to="" change="" a="" vector="" you="" must="" pass="" by="" reference="" (&).="" if="" you="" have="" arrays,="" you="" must="" pass="" size="" and="" the="" array,="" but="" arrays="" are="" already="" pointers,="" so="" do="" not="" use="" &="" when="" passing="" an="" array.="" each="" menu="" item="" will="" have="" a="" corresponding="" function,="" and="" the="" definition="" of="" the="" function="" will="" be="" found="" in="" the="" file="" functions.h.="" also,="" your="" operator="">< function="" for="" dealer="" and="" car="" will="" be="" implemented="" in="" your="" functions.h.="" all="" input/output="" will="" be="" done="" in="" the="" functions="" and="" not="" in="" main="" (except="" asking="" for="" what="" menu="" option="" the="" user="" wants).="" the="" following="" are="" the="" details="" for="" each="" of="" your="" menu="" options:="" 1.="" read="" dealers="" and="" cars="" from="" file="" 2.="" display="" dealers="" 3.="" choose="" a="" dealer="" number,="" display="" cars="" 4.="" choose="" a="" dealer="" number,="" add="" car="" 5.="" choose="" a="" dealer="" number,="" list="" cars="" and="" modify="" a="" car="" (extra="" credit)="" 6.="" choose="" a="" dealer,="" sort="" cars="" by="" vin="" (extra="" credit)="" 7.="" write="" dealers="" and="" cars="" to="" file.="" 8.="" exit="" option="" 1.="" read="" dealers="" and="" cars="" from="" file="" pass="" the="" vector="" of="" dealers="" (from="" main)="" into="" the="" function="" by="" reference.="" each="" dealer="" will="" have="" a="" name="" and="" number="" followed="" by="" the="" number="" of="" cars="" in="" the="" dealership="" (on="" separate="" lines).="" then="" you="" will="" read="" in="" a="" vin,="" make,="" model,="" year="" and="" price="" for="" each="" car="" (on="" separate="" lines).="" you="" can="" assume="" that="" the="" number="" of="" cars="" as="" well="" as="" the="" vin,="" make,="" model,="" year="" and="" price="" will="" be="" complete="" for="" each="" car.="" each="" dealer="" can="" have="" a="" file="" format="" as="" follows:="" dealer="" name="" dealer="" number="" number="" of="" cars="" e.g.="" 2="" car1="" vin="" car1="" make="" car1="" model="" car1="" year="" car1="" price="" car2="" vin="" car2="" make="" car2="" model="" car2="" year="" car2="" price="" dealer="" name="" dealer="" number="" number="" of="" cars="" e.g.="" 1="" car1="" vin="" car1="" make="" car1="" model="" car1="" year="" car1="" price="" don’t="" forget,="" between="">< and="" a="" getline="" you="" must="" use="" a="" .ignore(="" )="" (e.g.="" infile.ignore(="" )="" )="" here="" is="" an="" example="" of="" the="" input="" file:="" in.txt="" john="" elway="" dodge="" 123="" 2="" vin123="" dodge="" ram="" 1500="" quad="" cab="" 2017="" 45186.00="" vin456="" chevrolet="" traverse="" premier="" suv="" 2017="" 47868.00="" tesla="" cherry="" creek="" 234="" 1="" vin789="" tesla="" model="" x="" 2017="" 105200="" option="" 2.="" display="" dealers="" pass="" the="" vector="" of="" dealers="" (from="" main)="" into="" the="" function="" by="" reference.="" display="" the="" dealer="" name="" and="" number="" for="" each="" dealer="" (put="" a="" blank="" line="" between="" dealers).="" use="" the="">< operator="" with="" cout="" (cout="">< dealer[x];)="" option="" 3.="" choose="" a="" dealer="" number,="" display="" cars="" pass="" the="" vector="" of="" dealers="" (from="" main)="" into="" the="" function="" by="" reference.="" display="" the="" dealer="" names="" and="" numbers="" (menu="" #2).="" ask="" the="" user="" for="" the="" dealer="" number,="" display="" all="" of="" the="" cars="" by="" using="" a="" for="" loop="" (from="" zero="" to="" size="" of="" the="" car="" array)="" using="" the="">< operator="" with="" cout="" (="" cout="">< dealer[x].cararrayptr[x];) option 4. choose a dealer number, add car pass the vector of dealers (from main) into the function by reference. a) display the dealer names and numbers (menu #2). b) ask the user for the dealer number then the new car information. follow the steps found in csci 1411 lab 09 to increase the dynamic array. (essentially you will make a new array, one bigger than the previous car array. then you will copy everything over from the old car array to the new one. then you will point the car pointer to the new array) you can earn up to 20% extra credit (48/40) for completing 5 and 6 as long as you get at least 80% on the required tasks. option 5. choose a dealer number, list cars and modify a car (extra credit) pass the vector of dealers (from main) into the function by reference. display the dealer names and numbers (menu #2). ask the user for the dealer number, display cars for that dealer. ask the user to enter the vin number for the car to modify. the user will enter new car information including car vin, make, model, year and price. update the car information in the car array of the dealer. this requires accurate access of the dealer car element. option 6. choose a dealer, sort cars by vin (extra credit) pass the vector of dealers (from main) into the function by reference. display the dealer names and numbers (menu #2). ask the user for the dealer number. sort the cars by vin and display them (with blank lines between each car) option 7. write dealers and cars to file. pass the vector of dealers (from main) into the function by reference. also pass in the filestream (from main) by reference. call the output file out.txt. write all of the dealers and cars to a separate output file in the same format as in item #1. this should include all changes to the vector and dynamic array (including add, delete, modify, sorting etc.) option 8. exit out of the program what to submit: submit to canvas main.cpp, functions.h, dealer.h and dealer.cpp and the in.txt files. each must be complete with your name on it. if you complete the extra credit, you must have 7 menu items and this must be documented in your main.cpp. note: you must document all your code and reference any code that you took from any source (including the internet, your book, someone else). failure to do so may result in a grade of zero for each student with “too similar” code. you can work together with big ideas, but all code must be your own. page 6 of 7 dealer[x].cararrayptr[x];)="" option="" 4.="" choose="" a="" dealer="" number,="" add="" car="" pass="" the="" vector="" of="" dealers="" (from="" main)="" into="" the="" function="" by="" reference.="" a)="" display="" the="" dealer="" names="" and="" numbers="" (menu="" #2).="" b)="" ask="" the="" user="" for="" the="" dealer="" number="" then="" the="" new="" car="" information.="" follow="" the="" steps="" found="" in="" csci="" 1411="" lab="" 09="" to="" increase="" the="" dynamic="" array.="" (essentially="" you="" will="" make="" a="" new="" array,="" one="" bigger="" than="" the="" previous="" car="" array.="" then="" you="" will="" copy="" everything="" over="" from="" the="" old="" car="" array="" to="" the="" new="" one.="" then="" you="" will="" point="" the="" car="" pointer="" to="" the="" new="" array)="" you="" can="" earn="" up="" to="" 20%="" extra="" credit="" (48/40)="" for="" completing="" 5="" and="" 6="" as="" long="" as="" you="" get="" at="" least="" 80%="" on="" the="" required="" tasks.="" option="" 5.="" choose="" a="" dealer="" number,="" list="" cars="" and="" modify="" a="" car="" (extra="" credit)="" pass="" the="" vector="" of="" dealers="" (from="" main)="" into="" the="" function="" by="" reference.="" display="" the="" dealer="" names="" and="" numbers="" (menu="" #2).="" ask="" the="" user="" for="" the="" dealer="" number,="" display="" cars="" for="" that="" dealer.="" ask="" the="" user="" to="" enter="" the="" vin="" number="" for="" the="" car="" to="" modify.="" the="" user="" will="" enter="" new="" car="" information="" including="" car="" vin,="" make,="" model,="" year="" and="" price.="" update="" the="" car="" information="" in="" the="" car="" array="" of="" the="" dealer.="" this="" requires="" accurate="" access="" of="" the="" dealer="" car="" element.="" option="" 6.="" choose="" a="" dealer,="" sort="" cars="" by="" vin="" (extra="" credit)="" pass="" the="" vector="" of="" dealers="" (from="" main)="" into="" the="" function="" by="" reference.="" display="" the="" dealer="" names="" and="" numbers="" (menu="" #2).="" ask="" the="" user="" for="" the="" dealer="" number.="" sort="" the="" cars="" by="" vin="" and="" display="" them="" (with="" blank="" lines="" between="" each="" car)="" option="" 7.="" write="" dealers="" and="" cars="" to="" file.="" pass="" the="" vector="" of="" dealers="" (from="" main)="" into="" the="" function="" by="" reference.="" also="" pass="" in="" the="" filestream="" (from="" main)="" by="" reference.="" call="" the="" output="" file="" out.txt.="" write="" all="" of="" the="" dealers="" and="" cars="" to="" a="" separate="" output="" file="" in="" the="" same="" format="" as="" in="" item="" #1.="" this="" should="" include="" all="" changes="" to="" the="" vector="" and="" dynamic="" array="" (including="" add,="" delete,="" modify,="" sorting="" etc.)="" option="" 8.="" exit="" out="" of="" the="" program="" what="" to="" submit:="" submit="" to="" canvas="" main.cpp,="" functions.h,="" dealer.h="" and="" dealer.cpp="" and="" the="" in.txt="" files.="" each="" must="" be="" complete="" with="" your="" name="" on="" it.="" if="" you="" complete="" the="" extra="" credit,="" you="" must="" have="" 7="" menu="" items="" and="" this="" must="" be="" documented="" in="" your="" main.cpp.="" note:="" you="" must="" document="" all="" your="" code="" and="" reference="" any="" code="" that="" you="" took="" from="" any="" source="" (including="" the="" internet,="" your="" book,="" someone="" else).="" failure="" to="" do="" so="" may="" result="" in="" a="" grade="" of="" zero="" for="" each="" student="" with="" “too="" similar”="" code.="" you="" can="" work="" together="" with="" big="" ideas,="" but="" all="" code="" must="" be="" your="" own.="" page="" 6="" of="">
Answered Same DayDec 02, 2021

Answer To: CSCI1410 – PA3 Part I (10 Points): For this part of the assignment you will be create an outline in...

Sudipta answered on Dec 05 2021
138 Votes
HERE IS THE CODE FOR T HE REQUIRED PROBLEM AND I HAVE TESTED IT IN MY COMPUTER. IF YOU NEED SCREENSHOT OF ANSWERS THEN I WILL SEND THEM TOO.
//main.cpp
//Include this header file if using visual studio.
#include "stdafx.h"
//Include the needed files
#include
#include
#include
#include
#include "functions.h"
using namespace std;
//Define the function menu().
void menu()
{
     //Displ
ay the menu.
     cout << "Menu:" << endl;
     cout << "1. Read Dealers and Cars from file." << endl;
     cout << "2. Display Dealers." << endl;
     cout << "3. Choose a Dealer Number, Display Cars." <<
     endl;
     cout << "4. Choose a Dealer Number, Add Car." << endl;
     cout << "5. Choose a Dealer, Sort Cars by VIN." <<
     endl;
     cout << "6. Write Dealers and Cars to file." << endl;
     cout << "7. Exit." << endl;
     cout << endl;
}
//Start the main() method.
int main()
{
     //Declare the required variables.
     vector dealerlist;
     int option;
     ofstream outFile;
     while (1)
     {
          menu();
          cout << "Enter your option:";
          cin >> option;
          switch (option)
          {
               //Read dealer and car info
          case 1:
               ReadDealer(dealerlist);
               break;
               //Display dealer info
          case 2:
               displayDealers(dealerlist);
               break;
               //Display car info
          case 3:
               displayCars(dealerlist);
               break;
               //Add new car
          case 4:
               addNewCar(dealerlist);
               break;
               //Sort the cars by VIN.
          case 5:
               sortByVIN(dealerlist);
               break;
               //Write the contents to a seperate file.
          case 6:
               writeToFile(dealerlist, outFile);
               break;
               //Exit from program.
          case 7:
               system("pause");
               return 0;
          default:
               cout << "Invalid option." << endl;
          }
     }
     //Use this command if using visual studio.
     system("pause");
     return 0;
}
//Car.h
#pragma once
//Include the required header files.
#ifndef _CAR_H
#define _CAR_H
#include
#include
using namespace std;
//Define the car class.
class Car
{
     //Declare the required private member variables.
private:
     string VIN;
     string make;
     string model;
     int year;
     double price;
     //Declare the required public methods.
public:
     Car();
     Car(string vVIN, string vMake, string vModel, int
     vYear, double vPrice);
     //Accessors
     string getVIN();
     string getMake();
     string getModel();
     int getYear();
     double getPrice();
     //mutators
     void setVIN(string _VIN);
     void setMake(string _make);
     void setModel(string _model);
     void setYear(int _year);
     void setPrice(double _price);
     //Print
     friend ostream & operator<<(ostream & out, Car _car);
};
#endif
//Dealer.h
#pragma once
//Include the required header files.
#ifndef _DEALER_H
#define _DEALER_H
#include
#include
#include "Car.h"
using namespace std;
//Define the class Dealer
class Dealer
{
     //Declare the private required variables.
private:
     //variables.
     string dealerName;
     int dealerNumber;
     Car* carArrayPtr;
     int numberOfCars;
public:
     //Declare the public member functions.
     Dealer();
     Dealer(string dName, int dNumber);
     //mutators
     void setDealerName(string _dealerName);
     void setDealerNumber(int _dealerNumber);
     void setCarArrayPtr(Car * _carArrayPtr);
     void setNumberOfCars(int _numberOfCars);
     //Accessors
     string getDealerName();
     int getDealerNumber();
     int getNumberOfCars();
     Car* getCarArrayPtr();
     friend ostream & operator<<(ostream & out, Dealer
     _dealer);
};
#endif
//Car.cpp
//Include this header file if using visual studio.
#include "stdafx.h"
#include "Car.h"
//Define the required member functions of the Car class.
Car::Car()
{
     VIN = "";
     make = "";
     model = "";
     year = 0;
     price = 0;
}
Car::Car(string vVIN,...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here