subject

Problem 2. Vehicles Extension (Bonus) Use your solution of the previous task for starting point and add more functionality. Add new vehicle – Bus. Now
every vehicle has tank capacity and fuel quantity cannot fall below 0 (If fuel quantity become less than 0 print on
the console “Fuel must be a positive number”).
The vehicles cannot be filled with fuel more than their tank capacity. If you try to put more fuel in the tank than
the available space, print on the console “Cannot fit fuel in tank” and do not add any fuel in vehicles tank.
Add new command for the bus. The bus can drive with or without people. If the bus is driving with people, the airconditioner
is turned on and its fuel consumption per kilometer is increased with 1.4 liters. If there are no people
in the bus when driving the air-conditioner is turned off and does not increase the fuel consumption.
Input
 On the first three lines you will receive information about the vehicles in format:
Vehicle {initial fuel quantity} {liters per km} {tank capacity}
 On fourth line - number of commands N that will be given on the next N lines
 On the next N lines – commands in format
o Drive Car {distance}
o Drive Truck {distance}
o Drive Bus {distance}
o DriveEmpty Bus {distance}
o Refuel Car {liters}
o Refuel Truck {liters}
o Refuel Bus {liters}
Output
 After each Drive command print whether the Car/Truck was able to travel given distance in format if it’s
successful:
Car/Truck/Bus travelled {distance} km
 Or if it is not:
Car/Truck/Bus needs refueling
 If given fuel is ≤ 0 print “Fuel must be a positive number”.
 If given fuel cannot fit in car or bus tank print “Cannot fit fuel in tank”
 Finally print the remaining fuel for car, truck and bus rounded 2 digits after floating point in format:
Car: {liters}
Truck: {liters}
Page 3 of 3
Bus: {liters}
Example
Input Output
Car 30 0.04 70
Truck 100 0.5 300
Bus 40 0.3 150
8
Refuel Car -10
Refuel Truck 0
Refuel Car 10
Refuel Car 300
Drive Bus 10
Refuel Bus 1000
DriveEmpty Bus 100
Refuel Truck 1000
Fuel must be a positive number
Fuel must be a positive number
Cannot fit fuel in tank
Bus travelled 10 km
Cannot fit fuel in tank
Bus needs refueling
Cannot fit fuel in tank
Car: 40.00
Truck: 100.00
Bus: 23.00


Problem 2. Vehicles Extension (Bonus)

Use your solution of the previous task for starting point a

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 23:30
The keyboard usually has six rows of keys. which of the following is not one of the key group categories? letter keys number keys control keys graphic keys
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
Refer to the figure and match the theorem that supports the statement.1.if chords are =, then arcs are =.if bc = de, then arc bc = arc de2.if arcs are =, then chords are =.if arc bc = arc de, then bc = de3.diameters perpen
Answers: 3
question
Computers and Technology, 24.06.2019 16:00
Which of the following characters is acceptable to use in a filename? ? / – %
Answers: 1
question
Computers and Technology, 24.06.2019 16:50
7.23 main lab 7 - online shopping cart background this main lab extends the earlier prep lab "online shopping cart part 1". (you should save this as a separate project from the earlier prep lab). you will create an on-line shopping cart like you might use for your on-line purchases. the goal is to become comfortable with setting up classes and using objects. requirements this lab can be done individually or as pair programming. expanded itemtopurchase class (15 points) extend the itemtopurchase class as follows. we will not do unit testing in this lab so we will not be giving you the names of the member functions. create good ones on your own. create a parameterized constructor to assign item name, item description, item price, and item quantity (default values of "none" for name and description, and 0 for price and quantity). additional public member functions set an item description get an item description print the cost of an item - outputs the item name followed by the quantity, price, and subtotal (see example) print the description of an item - outputs the item name and description (see example) additional private data members a string for the description of the item. example output of the function which prints the cost of an item: bottled water 10 @ $1.50 = $15.00 example output of the function which prints the item description:
Answers: 1
You know the right answer?
Problem 2. Vehicles Extension (Bonus) Use your solution of the previous task for starting point an...
Questions
question
Mathematics, 07.05.2020 06:01
question
Mathematics, 07.05.2020 06:01
question
Mathematics, 07.05.2020 06:01
Questions on the website: 13722367