#include using namespace std; #define OKAY 0 //main UI function int DogUI(); //main engine function, returns neg number on error int DailyRate(int weight, int days); /* Function Name: DogUI Function Desc: Displays welcome message, and then asks the user to input dog weight and days per month to stay. It then calls the dailyRate() function to figure out the daily rate If there are no errors, it will print out the daily rate and the monthly total. If there are errors it will display an error message. */ int DogUI() { int status = OKAY; printf("Welcome to The Bone Jour Dog Day Care Center Monthly Fee Caclulator\n"); int days = 0; int weight = 0; int rate = 0; cout << "Dog weight (pounds):"; cin >> weight; cout << "Days per month to stay:"; cin >> days; rate = DailyRate(weight, days); if(weight > 0 && days > 0 && rate > 0) { printf("The daily rate is $%d and the monthly total is $%d\n", rate, rate * days); } else { printf("Dog weight and days to stay must both be greater than zero.\n"); } return status; } /* Function Name: dailyRate() Function Desc: Given the weight in pounds of dog and the days to stay per month, return the daily rate in dollars. Uses nested IF statements to first determine the weight of the dog and then determine which of the two possible rates for that weight should be used depending on the days to stay per month. Input: weight: integer weight of dog in pounds days: integer days the dog will stay per month Output: returns integer that is the daily rate in dollars, if there is an error it will return a negative value -1: negative weight -2: negative days */ int DailyRate(int weight, int days) { int retVal; if(weight < 0) { retVal = -1; } else if(days < 0) { retVal = -2; } else if(weight < 10) { if(days < 11) { retVal = 12; } else { retVal = 10; } } else if(weight < 35) { if(days < 11) { retVal = 16; } else { retVal = 13; } } else { if(days < 11) { retVal = 19; } else { retVal = 17; } } return retVal; }