Question: Class Attribute budget ( class - wide variable ) : Set to 5 0 , 0 0 0 . Instance Variables price ( double )

Class Attribute
budget (class-wide variable): Set to 50,000.
Instance Variables
price (double): Car price.model (string): Car make and model.pros (list of strings): List of pros (e.g., "Great gas mileage").cons (list of strings): List of cons (e.g., "Expensive repairs").propoints (list of integers): Priority points for pros (110).conpoints (list of integers): Priority points for cons (110).
Methods
Constructor:
Initializes the budget.Optionally accepts the model and price for initialization.
setcar: Sets the cars model and price.setpro: Adds a pro and its priority to the pros and propoints lists.setcon: Adds a con and its priority to the cons and conpoints lists.printit: Displays the budget, price, model, pros, cons, and their points in a formatted output.sum: Takes a list of integers (e.g., propoints) and returns the sum.compare:
Compares two car instances based on pros and cons.Formula:
ctotal = c_propoints - c_conpointsthistotal = this_propoints - this_conpoints
Determines which car has the higher total.Prints totals and the recommended car to buy.
Main Program (30 pts)
Create Car Instances
Create two instances (e.g., car1 and car2) of the Carprocon class.
Populate Data
Use the setcar method to set the model and price for each car.Add five pros and their priorities using the setpro method.Add five cons and their priorities using the setcon method.
Display Details
Use the printit method to display details of each car.
Compare Cars
Call the compare method for car2, passing car1 as the argument.The method determines which car is better and outputs the final recommendation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!