// Zeinalipour-Yazti Demetrios // csyiazti // cs10xx - // Lab Sec#24 // lab3 /* This program asks the user to enter a number of days It then converts the given days into years, months, weeks, and days, using 365 days in one year and 30 days in one month. It finally outputs nicely the result */ #include void main() { // These variables will hold the three values entered by the user int days_in; // the user input /* internal variables that hold the result */ int years; int months; int weeks; /* User-Input */ cout << "Please enter a number of days: "; cin >> days_in; /* Calculation */ years = days_in / 365; days_in %= 365; // OR days_in -= years * 365; // subtracting years months = days_in / 30; days_in %= 30; /* OR days_in -= months * 30; */ weeks = days_in / 7; days_in %= 7; /* OR days_in -= weeks * 7;*/ cout << years << " year(s) " << endl << endl; cout << months << " month(s)" << endl << endl; cout << weeks << " week(s) " << endl << endl; cout << days_in << " day(s) " << endl << endl; }