Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The code below the pics... thank you... I have two questions about my code which sub-case 5 under case 2 has a problem, I cannot

The code below the pics... thank you... I have two questions about my code which sub-case 5 under case 2 has a problem, I cannot return the last menu...

the second is the problem shows in pics.

image text in transcribed

#include

#include

#include

#include

using namespace std;

class Vehicle

{

friend class Truck;

private:

string name;

int passengers;

int wheels;

float maxspeed;

public:

void setname(string types) {name = types;}

void setpassengers(int riders) {passengers = riders;}

void setwheels(int tire) {wheels = tire;}

void setspeed(float rate) {maxspeed = rate;}

string getname() {return name;}

int getpassengers() {return passengers;}

int getwheels() {return wheels;}

float getspeed() {return maxspeed;}

void setall(string types, int riders, int tire, float rate) {name = types; passengers = riders; wheels = tire; maxspeed = rate;}

Vehicle(string types = "Motorcycle", int riders = 2, int tire = 2, float rate = 100)

{

name = types;

passengers = riders;

wheels = tire;

maxspeed = rate;

}

};

class Truck: public Vehicle

{

private:

float load;

float weight;

public:

void setload(float capacity) {load = capacity;}

void setweight(float pounds) {weight = pounds;}

float getload() {return load;}

float getweight() {return weight;}

Truck(float capacity = 0, float pounds = 2000)

{

load = capacity;

weight = pounds;

}

};

int main()

{

int option_1, option_2, option_2_1, option_3, option_5;

string types; int riders; int tire; float rate;

int const number = 5;

Truck Pickup_truck, Van;

Vehicle record[number] = {

{"Sedan", 5, 4, 80},

{"Bicycle", 1, 2, 30},

{"Unicycle", 1, 1, 15},

{"Row Boat", 3, 0, 10},

};

Pickup_truck.setall("Pickup Truck", 2, 4, 65);

Van.setall("Van", 2, 6, 70);

char ans = 'y';

while (ans == 'y')

{

system("cls");

cout

cout

cout

cout

cout

cout

cout

cout

cin >> option_1;

switch(option_1)

{

case 1:

{

int n;

system("cls");

for(int n = 0; n

{

cout

cout

cout

cout

}

cout

getch();

break;

}

case 2:

{

while (option_2 >= 1 || option_2

{

system("cls");

cout

cout

cout

cout

cout

cout

cout

cout

cin >> option_2;

if(option_2 == 6)

{

break;

}

while (option_2_1 >= 1 || option_2_1

{

system("cls");

cout

cout

cout

cout

cout

cout

cout

cout

cout

cout

cin >> option_2_1;

switch(option_2_1)

{

case 1:

{

cout

cin >> types;

record[option_2 - 1].setname(types);

break;

}

case 2:

{

cout

cin >> riders;

record[option_2 - 1].setpassengers(riders);

break;

}

case 3:

{

cout

cin >> tire;

record[option_2 - 1].setwheels(tire);

break;

}

case 4:

{

cout

cin >> rate;

record[option_2 - 1].setspeed(rate);

break;

}

case 5:

{

break;

}

default:

{

cout

getch();

break;

}

}

}

}

break;

}

case 3:

{

system("cls");

cout

cin >> option_3;

cout

cout

cout

cout

getch();

system("cls");

break;

}

case 4:

{

system("cls");

cout

cout

cout

cout

cout

cout

cout

getch();

system("cls");

break;

}

case 5:

{

float weight, load, speed;

int wheels;

while (option_5 >= 0 || option_5

{

system("cls");

cout

cout

cout

cout

cin >> option_5;

system("cls");

switch(option_5)

{

case 0:

{

cin.ignore();

cout

cin >> weight;

Pickup_truck.setweight(weight);

cout

cin >> load;

Pickup_truck.setload(load);

cout

cin >> wheels;

Pickup_truck.setwheels(wheels);

cout

cin >> speed;

Pickup_truck.setspeed(speed);

break;

}

case 1:

{

cin.ignore();

cout

cin >> weight;

Van.setweight(weight);

cout

cin >> load;

Van.setload(load);

cout

cin >> wheels;

Van.setwheels(wheels);

cout

cin >> speed;

Van.setspeed(speed);

break;

}

case 2:

{

system("cls");

break;

}

}

break;

}

break;

}

case 6:

{

system("cls");

cout

getch();

exit(0);

break;

}

default:

{

cout

cout

getch();

break;

}

}

}

}

28 29 30 31 32 nametYPES passengers riders: wheelstire maxspeedrate: 34 35 36 37 38 39 40 41 42 43 4 45 46 47 48 elass Truck: publie Vehicle privatC: loat load: float weight; public: void setload (float capacity) {load = capacity; } void setweight (float pounds) (weightpounds: float getload return load: float getweight freturn weight: Truck (float capacity=0, float pounds= 2000) load capacity: weight pounds 50 51 52 int main ) 54 int option, option_2, option 2_, option 3, option 5: string types int riders: int tire; float rate; int const number-5 Truck Pickup truck, Van; vehicle record [number] = { 56 57 58 59 60 61 62 63 64 65 "Sedan", 5, 4, 80 "Bicycle", 1, 2, 30, "Unicycle", 1, 1, 15), "Row Boat", 3, 0, 10, Pickup_truck.setall ("Pickup Truck", 2, 4, 65) Van.setall ("Van", 2, 6, 70) char ans = 'y'; 67 68 69 while (ansy Logs & others Code::Blocks X Search results XI Cocc X Build log X fBuild messages X)CppCheck a++ X ACppCheck Vera ++ messages XCscopeX Debugger X DoxyBlocks File Line Messago Build file: "no target" in "no project" (copiler: unknon In function int main C:\Users39411 C:User139411 C:Users139411.. 63arning: extended initializer lists only available vith -std-ot111 or-std-gnut+11 C: Usor 39411 63 63 rarning : extended 2n1 tial:or lists only available Vith -std=e++11 -std-gnu++11 or

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 Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

More Books

Students also viewed these Databases questions

Question

Create a workflow analysis.

Answered: 1 week ago