Answer to Question #274020 in C++ for Joy Chepkwemoi

Question #274020

Provide two methods, one of renting a vehicle and the other for returning a vehicle with the following method specifications.


The rent() methods accepts as argument the name and license number of the person renting the vehicle and also the number of days the vehicle will be on hire. If the vehicle is currently available it should set the status to '0', store the name, license number and days rented in the corresponding instance variables before returning true. Otherwise this method should simply return false. This method should have the following signature: public bool rent (string name, string license, int rented)


The returnBack() method should return 0(zero) if an attempt is made to return back a car which is not on loan, otherwise it should compute and return the charges for renting the vehicle (number of days multiplied by daily-rate). This method should have the following signature: public double returnBack ()

1
Expert's answer
2021-12-01T18:38:46-0500


SOLUTION CODE


#include <iostream>


using namespace std;
//define a struct to store the details of the person renting


struct person_renting
{
    char name[50];
    string licence;
    int rented;
    int status = 0;
   
}s[2];




public bool rent (string name, string license, int rented)
{
    if(status == 0)
	{
		s[0].name = name;
		s[0].license = name;
		s[0].rented = rented;
		
		return True;
	}
	else
	{
		return False;
	}	
}


//declare a variable for daily rate
 int daily_rate = 1000;
public double returnBack ()
{
	if(status != 0)
	{
	    return s.rented  *daily-rate;	
	}
	else
	{
		return 0;
	}
	
}

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