Special cars
Здравейте, ще може ли някакво решение на тази задача.
Problem 5. Special Cars
This is the final and most interesting problem in this lab. Until you receive the command "No more tires", you will be given tire info in the format:
{year} {pressure}
{year} {pressure}
…
"No more tires"
You have to collect all the tires provided. Next, until you receive the command "Engines done" you will be given engine info and you also have to collect all that info.
{horsePower} {cubicCapacity}
{horsePower} {cubicCapacity}
…
The final step - until you receive "Show special", you will be given information about cars in the format:
{make} {model} {year} {fuelQuantity} {fuelConsumption} {engineIndex} {tiresIndex}
…
Every time you have to create a new Car with the information provided. The car engine is the provided engineIndex and the tires are tiresIndex. Finally, collect all the created cars. When you receive the command "Show special", drive 20 kilometers all the cars, which were manufactured during 2017 or after, have horse power above 330 and the sum of their tire pressure is between 9 and 10. Finally, print information about each special car in the following format:
"Make: {specialCar.Make}"
"Model: {specialCar.Model}"
"Year: {specialCar.Year}"
"HorsePowers: {specialCar.Engine.HorsePower}"
"FuelQuantity: {specialCar.FuelQuantity}"
Input |
Output |
2 2.6 3 1.6 2 3.6 3 1.6 1 3.3 2 1.6 5 2.4 1 3.2 No more tires 331 2.2 145 2.0 Engines done Audi A5 2017 200 12 0 0 BMW X5 2007 175 18 1 1 Show special |
Make: Audi Model: A5 Year: 2017 HorsePowers: 331 FuelQuantity: 197.6 |