// 22.5HV2 Software Engineering II // Unit 1 Exercise 5 #include #include bool verify(float); bool verify(int, int); bool verify(int, int, int); void main() { float percent; int hour, minute; int day, month, year; do { cout << "Please enter a percentage (0-100) : "; cin >> percent; } while (!verify(percent)); do { cout << "Please enter a time (hour, minute) : "; cin >> hour >> minute; } while (!verify(hour,minute)); do { cout << "Please enter a date (day, month, year) : "; cin >> day >> month >> year; } while (!verify(day,month,year)); cout << "You entered:" << endl << endl; cout << setprecision(2); cout << setw(15) << "Percentage: " << percent << "%" << endl; cout << setw(15) << "Time: " << setfill('0') << setw(2) << hour << ":" << setw(2) << minute << endl; cout << setfill(' ') << setw(15) << "Date: " << day << "/" << month << "/" << year << endl; } bool verify(float p) { if ( p<0.0 || p>100.0 ) return false; else return true; } bool verify(int h, int m) { if ( h<0 || h>23 || m<0 || m>59 ) return false; else return true; } bool verify(int d, int m, int y) { if ( d<0 || d>31 || m<0 || m>12 || y<0 || y>99 ) return false; else return true; }