subject
Computers and Technology, 05.05.2021 17:20 DD8156

Problem 1. Vehicles Write a program that models 2 vehicles (Car and Truck) and will be able to simulate driving and refueling them in
the summer. Car and truck both have fuel quantity, fuel consumption in liters per km and can be driven given
distance and refueled with given liters. But in the summer both vehicles use air conditioner and their fuel
consumption per km is increased by 0.9 liters for the car and with 1.6 liters for the truck. Also the truck has a tiny
hole in his tank and when it gets refueled it gets only 95% of given fuel. The car has no problems when refueling and
adds all given fuel to its tank. If vehicle cannot travel given distance its fuel does not change.
Input
 On the first line - information about the car in format {Car {fuel quantity} {liters per km}}
 On the second line – info about the truck in format {Truck {fuel quantity} {liters per km}}
 On third 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 Refuel Car {liters}
o Refuel Truck {liters}
Output
After each Drive command print whether the Car/Truck was able to travel given distance in format if it’s successful.
Print the distance with two digits after the decimal separator except trailing zeros.
Car/Truck travelled {distance} km
Or if it is not:
Car/Truck needs refueling
Finally print the remaining fuel for both car and truck:
Car: {liters}
Truck: {liters}
Example #1
Input Output
Car 15 0.3
Truck 100 0.9
4
Drive Car 9
Drive Car 30
Refuel Car 50
Drive Truck 10
Car travelled 9 km
Car needs refueling
Truck travelled 10 km
Car: 54.20
Truck: 75.00
Page 2 of 3
Example #2
Input Output
Car 30.4 0.4
Truck 99.34 0.9
5
Drive Car 500
Drive Car 13.5
Refuel Truck 10.300
Drive Truck 56.2
Refuel Car 100.2
Car needs refueling
Car travelled 13.5 km
Truck needs refueling
Car: 113.05
Truck: 109.13


Problem 1. Vehicles

Write a program that models 2 vehicles (Car and Truck) and will be able to si

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 15:30
To increase sales, robert sends out a newsletter to his customers each month, letting them know about new products and ways in which to use them. in order to protect his customers' privacy, he uses this field when addressing his e-mail. attach bcc forward to
Answers: 2
question
Computers and Technology, 22.06.2019 21:30
The salespeople at hyperactive media sales all use laptop computers so they can take data with them on the road. you are a salesperson for superduper lightspeed computers talking to hyperactive media sales about upgrading the laptops to windows 10. explain how network location awareness in windows 10 would make the laptops more secure.
Answers: 3
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 23.06.2019 21:20
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
You know the right answer?
Problem 1. Vehicles Write a program that models 2 vehicles (Car and Truck) and will be able to sim...
Questions
question
Mathematics, 08.03.2021 06:10
question
Mathematics, 08.03.2021 06:10
question
Mathematics, 08.03.2021 06:10
question
Mathematics, 08.03.2021 06:10
Questions on the website: 13722363