Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Analyze the working of given code and complete the code for sortByMake()function and paste it in the provided space #include using namespace std; struct Date

Analyze the working of given code and complete the code for sortByMake()function and paste it in the provided space

#include

using namespace std;

struct Date { int day; int year; string month; }; struct Vehicle { string make; string model; int engCapacity; string color; Date DOR; };

void showData(Vehicle ve[5]);//shows contents of data input by user Vehicle inputData (); //gets input from user void sortByMake(Vehicle ve[5]); // sort arrays of structure by Car Make

int main() { Vehicle v[5]; //Getting Input from user for (int i=0;i<5;i++) { v[i] = inputData(); //Input unsorted e.g car make suzuki, then honda, the tesla etc } //Displaying the contents of Input Array cout<<" Car Particulars are : "; showData(v); //Diplaying the Contents of array of structure after sorting cout<<" Car Particulars after sorting are : "; sortByMake(v); // you have to write the code for sorting by car make in this function } void showData (Vehicle ve[5]) { for(int i=0;i<5;i++) { cout<<"Make : "<

Vehicle inputData () { Vehicle car; cout<<"Enter Data For Car : "; cout<<"Make : "; cin>>car.make; cout<<"Model : "; cin>>car.model; cout<<"Engine Capacity : "; cin>>car.engCapacity; cout<<"Color : "; cin>>car.color; cout<<"Day of Reg : "; cin>>car.DOR.day; cout<<"Year of Reg : "; cin>>car.DOR.year; cout<<"Month of Reg : "; cin>>car.DOR.month; return car; }

void sortByMake(Vehicle ve[5]) { //Write the code for sorting structure of array, input by user by Car Make in Ascending Order showData(ve); }

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

More Books

Students also viewed these Databases questions

Question

If

Answered: 1 week ago