Answered step by step
Verified Expert Solution
Link Copied!

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 c99, 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 1 of chapter 4. 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
1// s i m p l e c o n d i t i o n a l
2 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 ;
3 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 sheet_music_cost 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 customer_type". An enum is
essentially a list of possible values. You can see the declaration of customer_type on the line 2 of that code.
Thats really two things put together:
1. enum customer_typeteacher, student defines two constants, teacher and student, that are a list of
possible values
2. surrounding that with "typedef ... customer_type" 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 "customer_type"
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
1 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 sheet_music_cost is named customer and has the
type customer_type. That means, well call the function like this:
1 s h e e t _ m u s i c _ c o s t (122.00, 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 112.73.
In your practice.c file, build the sheet_music_cost function.
2
Quadrants
The next problem is based on Chapter 4 Problem #6: given an x and a y, figure out which quadrant it is in.
Heres the framework from the .h file:
1// c h a p t e r 4 q u e s t i o n 6
2 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 ;
3 enum q u a d r a n t c h 4_ q u e s t i o n 6( 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 sheet_music_cost(double purchase, customer_type customer){
/* Your code here*/
return 0;
}
enum quadrant ch4_question6(double x, double y){
/* Your code here*/
return IV;
}
int leap(int year){
/* Your code here*/
return 1;
}
int day_number(int month, int day, int year){
/* Your code here*/
return 1;
}
pollutant_level_type emissions(enum pollutant_type p, double grams_per_mile, int odometer){
/* Your code here*/
return carbon_monoxide;
}
int quiz_score(int quizzes[], int number_of){
/* Your code here*/
return 1;
}
int drop_the_low_score(int quizzes[], int number_of){
/* Your code here*/
return 1;
}
int gcd(int n1, int n2){
/* Your code here*/
return 1;
}
int years_to_decay(double starting_amount, double target){
/* Your code here*/
return 1;
}
h file code:
#ifndef PROJECT2_PRACTICE_H
#define PROJECT2_PRACTICE_H
// simple conditional
typedef enum customer_type {teacher, student} customer_type;
double sheet_music_cost(double purchase, customer_type customer);
// simple conditional
char pass_fail(int current_grade);
char c_d_fail(int current_grade);
char letter_grade(int final_grade);
char plus_minus(int final_grade);
//chapter 4 question 6
enum quadrant{I, II, III, IV};
enum quadrant ch4_question6(double x, double y);
//chapter 4 question 7
int leap(int year);
int day_number(int month, int day, int year);
//chapter 4 question 8
enum pollutant_type{carbon_monoxide, hydrocarbons, nitrogen_oxides, nonmethane_hydrocarbons};
double emissions(enum pollutant_type p, double grams_per_mile, int odometer);
int quiz_score(int quizzes[], int number_of_quizzes);
int drop_the_low_score(int quizzes[], int number_of_quizzes);
// Chapter 5 question 5
int gcd(int n1, int n2);
// Chapter 5 question 11
// Chapter 5 question 15
#endif //PROJECT2_PRACTICE_H

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Conceptual Database Design An Entity Relationship Approach

Authors: Carol Batini, Stefano Ceri, Shamkant B. Navathe

1st Edition

0805302441, 978-0805302448

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago