Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do in clion c 9 9 , the c and h file are at the end. I tried to post picutres but i only
Please do in clion c the c and h file are at the end. I tried to post picutres but i only lets me do one now
Sheet Music Cost
This problem is based on problem of chapter Your job is to build a function that does the calculation that
problem describes. You DONT have to do any input or output. The function you need to build is described
in this part of the h file
s i m p l e c o n d i t i o n a l
t y p e d e f enum c u s t o m e r t y p e t e a c h e r s t u d e n t c u s t o m e r t y p e ;
d o u b l e s h e e t m u s i c c o s t d o u b l e p u r c h a s e c u s t o m e r t y p e c u s t o m e r ;
You can see one function declaration there. The functions name is sheetmusiccost and it takes two
parameters: the purchase prices which is a double so it holds a real number and customer. For the variable
purchase, its type is double. For the variable customer, its type is "enum customertype". An enum is
essentially a list of possible values. You can see the declaration of customertype on the line of that code.
Thats really two things put together:
enum customertypeteacher, student defines two constants, teacher and student, that are a list of
possible values
surrounding that with "typedef customertype" is declaring a new variable type for variables that
can only hold values in that enum. Now we can declare variables to have the type "customertype"
and those variables will only be able to have the value teacher or student.
For example, this will declare a variable and make it hold the value student
c u s t o m e r t y p e s a l l y s t u d e n t ;
Back to our function declaration, the second parameter to sheetmusiccost is named customer and has the
type customertype. That means, well call the function like this:
s h e e t m u s i c c o s t t e a c h e r
Hint: that the call for the first example in the book and, in that case, the function should return
In your practice.c file, build the sheetmusiccost function.
Quadrants
The next problem is based on Chapter Problem #: given an x and a y figure out which quadrant it is in
Heres the framework from the h file:
c h a p t e r q u e s t i o n
t y p e d e f enum q u a d r a n t I I I I I I IV q u a d r a n t ;
enum q u a d r a n t c h q u e s t i o n d o u b l e x d o u b l e y ;
Like the previous problem, this uses an enum for four quadrants. Thats the return type of the function, so
you are supposed to return I, II III, or IV Some conditionals is all it should take.
c file code:
#include "practice.h
#include
#include
double sheetmusiccostdouble purchase, customertype customer
Your code here
return ;
enum quadrant chquestiondouble x double y
Your code here
return IV;
int leapint year
Your code here
return ;
int daynumberint month, int day, int year
Your code here
return ;
pollutantleveltype emissionsenum pollutanttype p double gramspermile, int odometer
Your code here
return carbonmonoxide;
int quizscoreint quizzes int numberof
Your code here
return ;
int dropthelowscoreint quizzes int numberof
Your code here
return ;
int gcdint n int n
Your code here
return ;
int yearstodecaydouble startingamount, double target
Your code here
return ;
h file code:
#ifndef PROJECTPRACTICEH
#define PROJECTPRACTICEH
simple conditional
typedef enum customertype teacher student customertype;
double sheetmusiccostdouble purchase, customertype customer;
simple conditional
char passfailint currentgrade;
char cdfailint currentgrade;
char lettergradeint finalgrade;
char plusminusint finalgrade;
chapter question
enum quadrantI II III, IV;
enum quadrant chquestiondouble x double y;
chapter question
int leapint year;
int daynumberint month, int day, int year;
chapter question
enum pollutanttypecarbonmonoxide, hydrocarbons, nitrogenoxides, nonmethanehydrocarbons;
double emissionsenum pollutanttype p double gramspermile, int odometer;
int quizscoreint quizzes int numberofquizzes;
int dropthelowscoreint quizzes int numberofquizzes;
Chapter question
int gcdint n int n;
Chapter question
Chapter question
#endif PROJECTPRACTICEH
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