Task 1: A menu can easily be created using a simple do-while loop which prints options and waits for the user’s input. Design a function which prints the menu and waits for user input.
Task 2: Create a class for a delivery truck, DeliveryTruck. Start with a single data member of type string which will hold the advertising on the side of the truck. Your first menu option will display a default object of type DeliveryTruck.
Task 3: We want the delivery truck to hold a bunch of packages. Add a data member, thePackages, to your class that will represent these packages by containing their weights (int/double?) in an array (max 50 elements, or dynamic, you choose). Your first menu option will now display a default object of type DeliveryTruck including both data members.
Task 4: Let the truck owner change the advertising on his truck. Your second menu option should allow the user to input the advertising for the truck (a string; possibly multiple words) and will display the new result.
Task 5: There is a packing list stored in a data file on your system. It consists of real numbers representing the weights of packages, each on a separate line. Add a member function to your class that will take the filename as a parameter and read these values into thePackages. Add a menu option to test this feature.
Task 6: Add a data member to your class for the weight of your vehicle. Add a menu option to display the weight of your cargo, and the total weight of your loaded truck.
Task 7: Modify your code so that each package has an ID number (integer). Now the package files will contain not only a weight but also an ID. The ID will be in the first column, the weight will be in the second and the columns will be separated by a whitespace.
Task 8: Let the user determine if his/her package is on your truck (search by the ID number).
Task 9: Our delivery company owns many trucks, so each truck should have a TruckID which is a unique number.
Modify the DeliveryTruck class to have a TruckID which MUST be set when the truck is constructed. Provide an accessor function to get this truckID.
Task 10: Since our company owns many trucks, we’d like to be able to store all of those trucks in a class called DeliveryCompany. Create a class called DeliveryCompany which stores a vector of DeliveryTruck objects.
Task 11: Create a function in the DeliveryCompany class which will take an array (or vector) of delivery truck numbers and read their package files. Package files are store on the system with the number of the truck in the form of “truck112.txt”.
Task 12: Add a menu option for the user to enter the truck numbers of all trucks (end with a negative number) which will create the company.
Task 13: Add the necessary menu option and class functions which will allow the user to search the entire company for their package ID number…. Congratulations, you’re now the USPS.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#include "DeliveryCompany.h"

DeliveryCompany deliveryCompany;

string getInputString() {
    string input;
    getline(cin, input);
    return input;

int getInputInt() {
    string input;
    getline(cin, input);
    stringstream input_to_int(input);
    int input_int;
    input_to_int >> input_int;
    return input_int;

void printMenu() {
    vector<string> menu;
    menu.push_back("1. Add Trucks to Company");
    menu.push_back("2. Print Company");
    menu.push_back("3. Print Truck Advertising (enter id)");
    menu.push_back("4. Change Truck Advertising");

    cout << "\n===== Menu =====" << endl;
    for (int i = 0; i < menu.size(); i++) {
       cout << menu[i] << endl;

By purchasing this solution you'll be able to access the following files:

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats