Question
Please follow the instructions given in the Recitation document. Your inputs must be in the following order, and the properties of the car structure must
Please follow the instructions given in the Recitation document. Your inputs must be in the following order, and the properties of the car structure must have the following names EXACTLY as spelled and capitalized:
mass
passengers
isElectric
fuelORcharge
workPerUnit
Please make sure your string for an invalid car matches the string in the document EXACTLY.
Write a function that creates a structure that represents a car. It should take the following inputs: - mass, the mass of the car in kg - passengers, the number of passengers the car should hold - isElectric, a Boolean variable that indicates whether the car is electric (true) or not (false) - fuelORcharge, a number that is either the volume of fuel the car has OR the percent charge the battery of the car has - workPerUnit, the rate at which the cars engine converts fuel or battery life into forward energy Your program should then check to see if the car is valid. Invalid car properties include: - Values less than 0 for any numeric property. - A value greater than 100 for fuelORcharge if isElectric is true. Batteries cannot be more than 100% charged. If your car is invalid, your output car should simply be the string 'Invalid car parameters.' If your car is valid car should be a structure. Each property of car should have the same name and value as each input variable. So, if your input mass was 300, car.mass would also be 300
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started