Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am getting errors in this code and im not sure why. I have the questions first then the code at the bottom. Please do
I am getting errors in this code and im not sure why. I have the questions first then the code at the bottom. Please do in clion c and add the printf statements. thank you
Q: How Many Days
This problem is based on Chapter Problem #: Given a month, day, and year, calculate how many days
into the year that date is This is the framework:
c h a p t e r q u e s t i o n
i n t l e a p i n t y e a r ;
i n t daynumber i n t month i n t day i n t y e a r ;
The problem is really only asking you to build the daynumber function, but, its easier to build that if we
have a function that tells us whether a given year is a leap year. Therefore, build the leap function first and
have it return if the year is a leap year and zero otherwise. Then, use that to build the daynumber function.
Q: Pollutants
This problem is based on Chapter Problem # Given the pollutant type, how much is being emitted, and
the odometer reading of the car, you are supposed to calculate whether the car is legal within the limits or
illegal exceeding the limits
c h a p t e r q u e s t i o n
t y p e d e f enum p o l l u t a n t t y p e c a r b o n m o n o x i d e h y d r o c a r b o n s
n i t r o g e n o x i d e s n o n m e t h a n e h y d r o c a r b o n s p o l l u t a n t t y p e ;
t y p e d e f enum p o l l u t a n t l e v e l t y p e l e g a l i l l e g a l p o l l u t a n t l e v e l t y p e ;
p o l l u t a n t l e v e l t y p e e m i s s i o n s p o l l u t a n t t y p e p d o u b l e g r a m s p e r m i l e i n t o d o m e t e r ;
You see two typedefs here: one for a enum of the types of pollutants and one for an enum for legal or illegal.
Line is the specification of the function you are to build. It has three parameters:
pollutanttype p: one of the pollutanttype values
double grampermile: the rate the car is emitting that pollutant
int odomoter: how far the car has been driven
Your job is to make the function return either illegal or legal based on the table in the book. Note that the
values in the table ar
int leapint year
if year
if year
if year
return ; Leap year
else
return ; Not a leap year
else
return ; Leap year
else
return ; Not a leap year
int daynumberint month, int day, int year
int daysinmonth;
int daynumber ;
for int i ; i month; i
daynumber daysinmonthi ;
if leapyear && month
daynumber ; Account for leap day in February
daynumber day;
return daynumber;
enum pollutantleveltype emissionsenum pollutanttype p double gramspermile, int odometer
double limit;
if odometer
switch p
case carbonmonoxide:
limit ;
break;
case hydrocarbons:
limit ;
break;
case nitrogenoxides:
limit ;
break;
case nonmethanehydrocarbons:
limit ;
break;
else
switch p
case carbonmonoxide:
limit ;
break;
case hydrocarbons:
limit ;
break;
case nitrogenoxides:
limit ;
break;
case nonmethanehydrocarbons:
limit ;
break;
if gramspermile limit
return illegal;
else
return legal;
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