-
Notifications
You must be signed in to change notification settings - Fork 0
/
price.h
44 lines (32 loc) · 982 Bytes
/
price.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* price.h
*
* header file for inventory price data item
*
* CSCI 352, Spring 2017, Assignment 3
*
* David Bover, May 2017
*
*/
#ifndef PRICE_DEF
#define PRICE_DEF 1
#define NEWLINE 1
typedef struct price_struct {
int negative;
unsigned int dollars;
unsigned int cents;
} price_t, *price_ptr;
// display the price to file fp, preceded by before, followed by after
void write_price(FILE *fp, char *before, price_t p, char *after);
// create and return a price value from the parameters
price_t new_price(int dollars, int cents, int negative);
// return the sum of prices: p1 + p2
price_t price_add(price_t p1, price_t p2);
// return the difference of prices: p1 - p2
price_t price_subtract(price_t p1, price_t p2);
// return a price being the total cost of quantity of items each at price p
price_t price_multiply(price_t p, int quantity);
// compare two prices
// return <0 if p1<p2, 0 if p1==p2, >0 if p1>p2
int compare(price_t p1, price_t p2);
#endif