Question

In: Computer Science

Program to implement in c++ dont forget to implement the 2D array and print whether the...

Program to implement in c++

dont forget to implement the 2D array and print whether the vehicle is available or not! This is the main part that I dont know how to implement! no good rating if this isnt done.

Define a class Vehicle that has the following data members:  Model of the vehicle (e.g., Ford, Toyota) as a standard library string.  The date that vehicle has joined to the fleet use the class Date that has the following data members:month, day, year. The mileage of the vehicle as an integer.  A four digit id of the vehicle as a standard library string, such as string vehicle_id = "2345";  A two-dimensional 12-by-30 array of Boolean variables that shows whether the vehicle is available or has been rented out for each day of the year. If the vehicle is available on a given date then Boolean variable is true and if rented out is false. Each row of the array corresponds to a month and for simplicity we assume that the number of days in each month is 30.

Solutions

Expert Solution

#include<iostream>
#include<string>
using namespace std;

//date class
class date{
public:
int day,month,year;
date(){}
date(int d,int m,int y){
day = d;
month = m;
year=y;
}
};
//vehicle class
class vehicle{
public:
//class data members
string model, id;
date d;
int mileage;
bool calendar[12][30];

vehicle(){} //non-parameterized constructor
//parameterized constructor
vehicle(string m,string Id,date dd,int mil){
model = m;
id=Id;
d=dd;
mileage=mil;
}
//isAvialable function return value based on the date
bool isAvailable(date dd){
return calendar[dd.month][dd.day];
}
//by passing date, vehicle can be rented
void rentIt(date dd){
calendar[dd.month][dd.day] = false;
}
};
//main function
int main()
{
//sample test definitions
date d(21,10,2018);
vehicle v("Ford","1234",d,25);
if(v.isAvailable(d))
cout<<"Available";
else cout<<"Not";
return 0;
}

//output screenshot

//any query, post in the comment section


Related Solutions

. Write a program to print * in the following order using 2d array in java...
. Write a program to print * in the following order using 2d array in java                                              *             *             *             *             *                                              *             *             *             *                                              *             *             *                                              *             *                                                          *
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and...
Complete the given C++ program (prob1.cpp) to read an array of integers, print the array, and then find the index of the largest element in the array. You are to write two functions, printArray() and getIndexLargest(), which are called from the main function. printArray() outputs integers to std::cout with a space in between numbers and a newline at the end. getIndexLargest () returns the index of the largest element in the array. Recall that indexes start at 0. If there...
in C++ For this program, you are going to implement a stack using an array and...
in C++ For this program, you are going to implement a stack using an array and dynamic memory allocation. A stack is a special type of data structure that takes in values (in our case integers) one at a time and processes them in a special order. Specifically, a stack is what's called a first-in-last-out (FILO) data structure. That is to say, the first integer inserted into the stack is the last value to be processed. The last value in...
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes...
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes of the largest value stored in the 2D array. Specific requirements: (1) Your main function defines the 2D array a. You will need to prompt the user to specify the size of the 2D array b. You will need to prompt the user to put in numbers to initialize the array (2) Write a function to display the array that is visualized as rows...
Submit a well-commented C program.   Create code. That will build a random 8x8 2D array of...
Submit a well-commented C program.   Create code. That will build a random 8x8 2D array of small-case characters. Demonstrate how it functions by printing out the result on your screen. Add a function will print out a single line of the array. If the user enters a value between 0 and 7 to select to print out a single row of the original 2D array.                void printLine(char *,int);    // This is the prototype declaration             void printLine(char myArr[][])     //...
Lab 7 - 2D Arrays (C++) In main, declare and fill a 2D array with one...
Lab 7 - 2D Arrays (C++) In main, declare and fill a 2D array with one hundred rows and fifty columns. Iterate through each element and assign it a random value between -72 and 75 inclusive. Have your random number seed be 25. Create functions that do the following: 1. A function called “sum” that returns the sum of all the elements in your 2D Array. 2. A function called “average” that return the average value of the elements in...
C++ Program (Using 2D array and bubble sort to sort data) A company pays its salespeople...
C++ Program (Using 2D array and bubble sort to sort data) A company pays its salespeople on a commission basis.  The salespeople each receive $250 per week plus 11 percent of their gross sales for the sales period.  For example, a salesperson who grosses $5000 in sales in the period receives $250 plus 11 percent of $5000, or a total of $812.21.  Write a program (using an array of counters) determines for each salesperson their total sales, their salary and additional data points.  There...
write a c++ program. Define a class ‘Matrix’ which contain 2D int array ‘m’ of size...
write a c++ program. Define a class ‘Matrix’ which contain 2D int array ‘m’ of size 3x3 as private member.        There should be two public methods within the class definition namely: void setMatrixValue(int i, int j); that should set m[i][j] with user defined values int getMatrixValue(int i, int j); that should return m[i][j] Make a global function named ‘CrossProduct(Matrix m1, Matrix m2)’ that should compute the marix multiplication
Write a C program that generates the following 2D array. 64   32   16   8   4   2  ...
Write a C program that generates the following 2D array. 64   32   16   8   4   2   1 32   32   16   8   4   1   1 16   16   16   8   4   2   1 8   8   8   8   4   2   1 4   4   4   4   4   2   1 2   2   2   2   2   2   1 1   1   1   1   1   1   1
write a program which will prompt an array of 12 integers then print the array as...
write a program which will prompt an array of 12 integers then print the array as an array of 4 columns on 3 rows
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT