Answered step by step
Verified Expert Solution
Question
1 Approved Answer
6. Uber application: [Please read the whole problem before start solving] You are requested to create a simple application that estimates the cost of
6. Uber application: [Please read the whole problem before start solving] You are requested to create a simple application that estimates the cost of an Uber trip. In your application you need to ask the user to enter the car type (UberX, UberXL) and the distance (in kilometer). In a real scenario, the GPS mapping software would be able to determine the distance based on the destination address. Since we don't have this ability, we will simply ask the user. driveate a base class called UberX that has the following instance variables (plate_no, driver_id, driver_name, distance). (/1 pts) Create a no argument constructor for the UberX class that initializes the car type to "UberX" and the distance to 0. Create an overloaded constructor for the UberX class that initializes the car type and the distance to the values given by the class client (test application). (/2 pts) - create a method calc_fare() that calculates the fare of the ride of an UberX car based on the formula fare= 4.0+ distance * (1.12). - Create the accessor and mutator (set and get) methods for the distance. ( /1 pts) (/2 pts) - Create a derived class called UberXL that has the following instance variables (plate_no, driver_id, driver_name, distance, no_passengers). Override the calc_fare() method to calculate the fare based on the formula: fare= 6.5 + distance* (1.5) (/2 pts) In the main() method - - Create an object X1 of the UberX class. - - Create an object XL1 of the UberXL class. Set the distance of X1 to a value entered by the user. Set the distance of XL1 to 20.2km. (Add necessary code) Calculate and print the fare of each of X1 and XL1.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started