// Wyatt Vandenburg // Paintingco.cpp // the following code takes in the the size of a painting job and calculates the size of job, how many paint cans it // will take and the cost, next the program takes an inputed numeric date and calculates the day of the week, and // the calculates the correct month while considering if there is a leap year or not // Xcode #include #include #include using namespace std; void displayTitle(); void getData(int &length, int &width); char convert12Format(int &hour); int calcSqMeter(int length, int width); int calcTotalCans(int area); double calcCost(int cans); void displayResults(int area, int cans, double cost); bool isLeapYear(int year); int getYearValue(int year); int getMonthNumber(string month); int getMonthVa0lue(int m, int year); int dayOfWeek(int day, int month, int year); void displayMsg(int cans); int main() { int length, width, hour, minute, day, month, year; string weekDay[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}; string monthsInYear[] = {"January", "Feburary", "March","April", "May", "June", "July", "August", "September", "November", "Decemeber"}; // displayTitle(); getData(length, width); while (length != 0) { cout << " Enter the transaction time in 24-hour notation: " <> hour; cout<<" Minute: "; cin >> minute; cout << " Enter the transaction date (dd mm yyyy): "; cin >> day >> month >> year; int area = calcSqMeter(length, width); int cans = calcTotalCans(area); double cost = calcCost(cans); displayResults(area, cans, cost); int idx = dayOfWeek(day, month, year); char ampm = convert12Format(hour); cout << "\n\tDate/Time: " << weekDay[idx] <<", " << monthsInYear[month -1] << " " << day << ", " << year << " " << hour << ":" << minute; if(ampm == 'P') cout<<"PM" << endl; else cout <<"AM"<> length; if(length == 0) return; cout<<" Enter the width in meter...................."; cin >> width; } // this method converts 24 hour period into a 12 hour also is using call by reference char convert12Format(int &hour) { if(hour > 12) { hour = hour - 12; return 'P'; } return 'A'; } //function receives the values for length and width, and int calcSqMeter(int length, int width) { int height = 3; return length * width + 2 * height * (length + width); } //function calculates and returns the # of cans int calcTotalCans(int area) { int coverArea = 20; int cans = ceil((double)area/coverArea); // ceil will round the value up return cans; } //function calculates and returns the total cost double calcCost(int cans) { double price = 15.50; return cans * price; } // method displays numeric values and makes sure that the cost is set to two decimal places void displayResults(int area, int cans, double cost) { cout << "\n--------------------------------------------------------------------------"< 12 || month < 1) return -1; else if (month > 2 || !isLeapYear(year)) return modifier[month - 1]; else return (modifier[month - 1] + 6) % 7; } //function returns the day of the week of the specified date as an int (Sunday = 0, Monday = 1, etc.) int dayOfWeek(int d, int m, int y) { static int t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 }; y -= m < 3; return ( y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7; } // this fucntion will give the customer a free gift depending on the amount of cans they purchcase void displayMsg(int cans) { if(cans>1 && cans<4) cout<<"Gift: free paint brush\n "<