007-004-003
Class Aggregation: Car and Engine
Easy
Problem Description
class Aggregation: Car and Engine
In this problem, you will create a program that implements Engine and Car classes where Car holds an Engine as an aggregation field, reads a car name and horsepower from standard input, and displays the result to standard output.
Learning Objective: Understand aggregation relationship where one class contains another
Create Engine and Car classes where Car has an Engine. Display the engine horsepower along with car information.
Input
Line 1: Car name (string)
Line 2: Engine horsepower (integer)
Output
Car: [car name]
Engine: [horsepower] HP
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up