Софтуерно Инженерство
Loading...
Samuilow10eddy avatar Samuilow10eddy 4 Точки

Vechicle Catalogue - Object and Classes - Excersices

Здравейте, не мога да разбера къде бъркам.

https://pastebin.com/wB6FGUa6?fbclid=IwAR1S6ggjBkI8BWfMs2XSP2tm8YKG7bX46CjnokT-iXUJlM5oiJkljstyfyA

6.Vehicle Catalogue

You have to make a catalogue for vehicles. You will receive two types of vehicle - car or truck.

Until you receive the command "End" you will receive lines of input in the format:

{typeOfVehicle} {model} {color} {horsepower}

After the "End" command, you will start receiving models of vehicles. Print for every received vehicle its data in the format:

Type: {typeOfVehicle}

Model: {modelOfVehicle}

Color: {colorOfVehicle}

Horsepower: {horsepowerOfVehicle}

 

When you receive the command "Close the Catalogue", stop receiving input and print the average horsepower for the cars and for the trucks in the format:

"{typeOfVehicles} have average horsepower of {averageHorsepower}."

The average horsepower is calculated by dividing the sum of horsepower for all vehicles of the type by the total count of vehicles from the same type.

Format the answer to the 2nd decimal point.

Constraints

  • The type of vehicle will always be car or truck
  • You will not receive the same model twice
  • The received horsepower will be integer in the interval [1…1000]
  • You will receive at most 50 vehicles
  • Single whitespace will be used for separator

Examples

Input

Output

truck Man red 200

truck Mercedes blue 300

car Ford green 120

car Ferrari red 550

car Lamborghini orange 570

End

Ferrari

Ford

Man

Close the Catalogue

Type: Car

Model: Ferrari

Color: red

Horsepower: 550

Type: Car

Model: Ford

Color: green

Horsepower: 120

Type: Truck

Model: Man

Color: red

Horsepower: 200

Cars have average horsepower of: 413.33.

Trucks have average horsepower of: 250.00.

Тагове:
0
Fundamentals Module
mark79 avatar mark79 561 Точки

Здравей,

грешката ти е при изчислението на средните стойности за мощност когато в списъците нямаме коли или камиони.

Ето ти тест с който да пробваш .. може дори да махнеш и първият ред.

truck Man red 200
End
Close the Catalogue

Поздрави :)

0