Answer to Question #253807 in C++ for Navi

Question #253807
Design a Car model class under package :package6 with the following attributes:

Member Field Name
Type
licenceNumber
String
Model
String
currentMileage
Double
engineSize
Intege
Mark all the attributes as private & create appropriate Getters & Setters

Design another class as Main under package :package6, where you need to implement logic as follows:
Declare an array as Car with size 10.
Take 10 Carà ƒ ¢ € ™s information from user and store them in specified array.
Call findCarList method from Main class to get all cars information related to a given current Mileage & engine Size
Current Mileage & engine Size values should be taken from Main class and pass to findCarList method as argument as well as Car array (with size 10).
Design findCarList method in Car class as follows:
1
Expert's answer
2021-10-19T17:12:02-0400


#include<iostream>
using namespace std;
class Car{
private:
string licenceNumber;
string Model;
double currentMileage;
int engineSize;
public:
void setLicense(string l){
    licenceNumber = l;
}
void setModel(string m){
    Model = m;
}
void setCurrentMileage(double l){
    currentMileage = l;
}
void setEngine(int l){
    engineSize = l;
}


string getLicence(){
    return licenceNumber;
}


string getModel(){
    return Model;
}
double getCurrent(){
    return currentMileage;
}
int getEngineSize(){
    return engineSize;
}


};
class Main{
private:
Car c[10];
public:
void input(){
    cout<<"Enter the details for the cars:\n";
    for(int i=0; i<10; i++){
        cout<<"Enter the car license number";
        string license;
        cin>>license;
        cout<<"Enter the car model: \n";
        string model;
        cin>>model;
        cout<<"Enter the current milleage:\n";
        double mileage;
        cin>>mileage;
        cout<<"Enter the car engine size:\n";
        int engine;
        cin>>engine;
        c[i].setLicense(license);
        c[i].setModel(model);
        c[i].setEngine(engine);
        c[i].setCurrentMileage(mileage);
        
    }
    
    }
    void output(){
        cout<<"The details stored are: "<<endl;
        for(int i=0; i<10; i++){
            cout<<"License Number:  "<<c[i].getLicence()<<endl;
            cout<<"Model:  "<<c[i].getModel()<<endl;
            cout<<"Current Mileage:  "<<c[i].getCurrent()<<endl;
            cout<<"Engine Size:  "<<c[i].getEngineSize()<<endl;
            
        }
}


};


int main(){


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS