Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int days;
int date;
int month;
cout << "Please enter a number from 1-12 to represent a month: " ;
cin >> month;
switch(month){
case 1:
cout << "January" << endl;
days = 31;
break;
case 2:
cout << "February" << endl;
days = 28;
break;
case 3:
cout << "March" << endl;
days = 31;
break;
case 4:
cout << "April" << endl;
days = 30;
break;
case 5:
cout << "May" << endl;
days = 31;
break;
case 6:
cout << "June" << endl;
days = 30;
break;
case 7:
cout << "July" << endl;
days = 31;
break;
case 8:
cout << "August" << endl;
days = 31;
break;
case 9:
cout << "September" << endl;
days = 30;
break;
case 10:
cout << "October" << endl;
days = 31;
break;
case 11:
cout << "November" << endl;
days = 30;
break;
case 12:
cout << "December" << endl;
days = 31;
break;
default:
cout << "Please enter a vaild month: " ;
}
cout << "Please enter a number from 1-" << days << " to represent a date: ";
cin >> date;
switch(date){
case 1:
cout << month << "/1" << endl;
break;
case 2:
cout << month << "/2" << endl;
break;
case 3:
cout << month << "/3" << endl;
break;
case 4:
cout << month << "/4" << endl;
break;
case 5:
cout << month << "/5" << endl;
break;
case 6:
cout << month << "/6" << endl;
break;
case 7:
cout << month << "/7" << endl;
break;
case 8:
cout << month << "/8" << endl;
break;
case 9:
cout << month << "/9" << endl;
break;
case 10:
cout << month << "/10" << endl;
break;
case 11:
cout << month << "/11" << endl;
break;
case 12:
cout << month << "/12" << endl;
break;
case 13:
cout << month << "/13" << endl;
break;
case 14:
cout << month << "/14" << endl;
break;
case 15:
cout << month << "/15" << endl;
break;
case 16:
cout << month << "/16" << endl;
break;
case 17:
cout << month << "/17" << endl;
break;
case 18:
cout << month << "/18" << endl;
break;
case 19:
cout << month << "/19" << endl;
break;
case 20:
cout << month << "/20" << endl;
break;
case 21:
cout << month << "/21" << endl;
break;
case 22:
cout << month << "/22" << endl;
break;
case 23:
cout << month << "/23" << endl;
break;
case 24:
cout << month << "/24" << endl;
break;
case 25:
cout << month << "/25" << endl;
break;
case 26:
cout << month << "/26" << endl;
break;
case 27:
cout << month << "/27" << endl;
break;
case 28:
cout << month << "/28" << endl;
break;
case 29:
cout << month << "/29" << endl;
break;
case 30:
cout << month << "/30" << endl;
break;
case 31:
cout << month << "/31" << endl;
break;
default:
cout << "Invalid date. Please try again: ";
}
if (date + 14 > days)
cout << "Two weeks from your selected date is " << (month + 1) << "/" << ((date + 14) - 30) << endl;
else cout << "Two weeks from your selected date is " << month << "/" << (date + 14) << endl;
return 0;
}
btw this doesnt loop back when you put in an incorrect date/monthJim Perry said:Just wait until the day they assign you something like this (this is in C++, by the way):
Code:#include <iostream> #include <string> using namespace std; int main() { int days; int date; int month; cout << "Please enter a number from 1-12 to represent a month: " ; cin >> month; switch(month){ case 1: cout << "January" << endl; days = 31; break; case 2: cout << "February" << endl; days = 28; break; case 3: cout << "March" << endl; days = 31; break; case 4: cout << "April" << endl; days = 30; break; case 5: cout << "May" << endl; days = 31; break; case 6: cout << "June" << endl; days = 30; break; case 7: cout << "July" << endl; days = 31; break; case 8: cout << "August" << endl; days = 31; break; case 9: cout << "September" << endl; days = 30; break; case 10: cout << "October" << endl; days = 31; break; case 11: cout << "November" << endl; days = 30; break; case 12: cout << "December" << endl; days = 31; break; default: cout << "Please enter a vaild month: " ; } cout << "Please enter a number from 1-" << days << " to represent a date: "; cin >> date; switch(date){ case 1: cout << month << "/1" << endl; break; case 2: cout << month << "/2" << endl; break; case 3: cout << month << "/3" << endl; break; case 4: cout << month << "/4" << endl; break; case 5: cout << month << "/5" << endl; break; case 6: cout << month << "/6" << endl; break; case 7: cout << month << "/7" << endl; break; case 8: cout << month << "/8" << endl; break; case 9: cout << month << "/9" << endl; break; case 10: cout << month << "/10" << endl; break; case 11: cout << month << "/11" << endl; break; case 12: cout << month << "/12" << endl; break; case 13: cout << month << "/13" << endl; break; case 14: cout << month << "/14" << endl; break; case 15: cout << month << "/15" << endl; break; case 16: cout << month << "/16" << endl; break; case 17: cout << month << "/17" << endl; break; case 18: cout << month << "/18" << endl; break; case 19: cout << month << "/19" << endl; break; case 20: cout << month << "/20" << endl; break; case 21: cout << month << "/21" << endl; break; case 22: cout << month << "/22" << endl; break; case 23: cout << month << "/23" << endl; break; case 24: cout << month << "/24" << endl; break; case 25: cout << month << "/25" << endl; break; case 26: cout << month << "/26" << endl; break; case 27: cout << month << "/27" << endl; break; case 28: cout << month << "/28" << endl; break; case 29: cout << month << "/29" << endl; break; case 30: cout << month << "/30" << endl; break; case 31: cout << month << "/31" << endl; break; default: cout << "Invalid date. Please try again: "; } if (date + 14 > days) cout << "Two weeks from your selected date is " << (month + 1) << "/" << ((date + 14) - 30) << endl; else cout << "Two weeks from your selected date is " << month << "/" << (date + 14) << endl; return 0; }
I think you'll like C++.
Megumin said:btw this doesnt loop back when you put in an incorrect date/monthJim Perry said:Just wait until the day they assign you something like this (this is in C++, by the way):
Code:#include <iostream> #include <string> using namespace std; int main() { int days; int date; int month; cout << "Please enter a number from 1-12 to represent a month: " ; cin >> month; switch(month){ case 1: cout << "January" << endl; days = 31; break; case 2: cout << "February" << endl; days = 28; break; case 3: cout << "March" << endl; days = 31; break; case 4: cout << "April" << endl; days = 30; break; case 5: cout << "May" << endl; days = 31; break; case 6: cout << "June" << endl; days = 30; break; case 7: cout << "July" << endl; days = 31; break; case 8: cout << "August" << endl; days = 31; break; case 9: cout << "September" << endl; days = 30; break; case 10: cout << "October" << endl; days = 31; break; case 11: cout << "November" << endl; days = 30; break; case 12: cout << "December" << endl; days = 31; break; default: cout << "Please enter a vaild month: " ; } cout << "Please enter a number from 1-" << days << " to represent a date: "; cin >> date; switch(date){ case 1: cout << month << "/1" << endl; break; case 2: cout << month << "/2" << endl; break; case 3: cout << month << "/3" << endl; break; case 4: cout << month << "/4" << endl; break; case 5: cout << month << "/5" << endl; break; case 6: cout << month << "/6" << endl; break; case 7: cout << month << "/7" << endl; break; case 8: cout << month << "/8" << endl; break; case 9: cout << month << "/9" << endl; break; case 10: cout << month << "/10" << endl; break; case 11: cout << month << "/11" << endl; break; case 12: cout << month << "/12" << endl; break; case 13: cout << month << "/13" << endl; break; case 14: cout << month << "/14" << endl; break; case 15: cout << month << "/15" << endl; break; case 16: cout << month << "/16" << endl; break; case 17: cout << month << "/17" << endl; break; case 18: cout << month << "/18" << endl; break; case 19: cout << month << "/19" << endl; break; case 20: cout << month << "/20" << endl; break; case 21: cout << month << "/21" << endl; break; case 22: cout << month << "/22" << endl; break; case 23: cout << month << "/23" << endl; break; case 24: cout << month << "/24" << endl; break; case 25: cout << month << "/25" << endl; break; case 26: cout << month << "/26" << endl; break; case 27: cout << month << "/27" << endl; break; case 28: cout << month << "/28" << endl; break; case 29: cout << month << "/29" << endl; break; case 30: cout << month << "/30" << endl; break; case 31: cout << month << "/31" << endl; break; default: cout << "Invalid date. Please try again: "; } if (date + 14 > days) cout << "Two weeks from your selected date is " << (month + 1) << "/" << ((date + 14) - 30) << endl; else cout << "Two weeks from your selected date is " << month << "/" << (date + 14) << endl; return 0; }
I think you'll like C++.
you should use labels/goto or encompass date/month in a while loop or something if you learned those
make sure you always debug!
ooh i'm currently doing something like this in computer studiesMaria Renard said:Finally finished my third assignment for Turing for Computer Science.
try this (i added comments to things i put in):Jim Perry said:Megumin said:btw this doesnt loop back when you put in an incorrect date/monthJim Perry said:Just wait until the day they assign you something like this (this is in C++, by the way):
Code:#include <iostream> #include <string> using namespace std; int main() { int days; int date; int month; cout << "Please enter a number from 1-12 to represent a month: " ; cin >> month; switch(month){ case 1: cout << "January" << endl; days = 31; break; case 2: cout << "February" << endl; days = 28; break; case 3: cout << "March" << endl; days = 31; break; case 4: cout << "April" << endl; days = 30; break; case 5: cout << "May" << endl; days = 31; break; case 6: cout << "June" << endl; days = 30; break; case 7: cout << "July" << endl; days = 31; break; case 8: cout << "August" << endl; days = 31; break; case 9: cout << "September" << endl; days = 30; break; case 10: cout << "October" << endl; days = 31; break; case 11: cout << "November" << endl; days = 30; break; case 12: cout << "December" << endl; days = 31; break; default: cout << "Please enter a vaild month: " ; } cout << "Please enter a number from 1-" << days << " to represent a date: "; cin >> date; switch(date){ case 1: cout << month << "/1" << endl; break; case 2: cout << month << "/2" << endl; break; case 3: cout << month << "/3" << endl; break; case 4: cout << month << "/4" << endl; break; case 5: cout << month << "/5" << endl; break; case 6: cout << month << "/6" << endl; break; case 7: cout << month << "/7" << endl; break; case 8: cout << month << "/8" << endl; break; case 9: cout << month << "/9" << endl; break; case 10: cout << month << "/10" << endl; break; case 11: cout << month << "/11" << endl; break; case 12: cout << month << "/12" << endl; break; case 13: cout << month << "/13" << endl; break; case 14: cout << month << "/14" << endl; break; case 15: cout << month << "/15" << endl; break; case 16: cout << month << "/16" << endl; break; case 17: cout << month << "/17" << endl; break; case 18: cout << month << "/18" << endl; break; case 19: cout << month << "/19" << endl; break; case 20: cout << month << "/20" << endl; break; case 21: cout << month << "/21" << endl; break; case 22: cout << month << "/22" << endl; break; case 23: cout << month << "/23" << endl; break; case 24: cout << month << "/24" << endl; break; case 25: cout << month << "/25" << endl; break; case 26: cout << month << "/26" << endl; break; case 27: cout << month << "/27" << endl; break; case 28: cout << month << "/28" << endl; break; case 29: cout << month << "/29" << endl; break; case 30: cout << month << "/30" << endl; break; case 31: cout << month << "/31" << endl; break; default: cout << "Invalid date. Please try again: "; } if (date + 14 > days) cout << "Two weeks from your selected date is " << (month + 1) << "/" << ((date + 14) - 30) << endl; else cout << "Two weeks from your selected date is " << month << "/" << (date + 14) << endl; return 0; }
I think you'll like C++.
you should use labels/goto or encompass date/month in a while loop or something if you learned those
make sure you always debug!
Noted. I thought I fixed that but I'll try to hit up my uncle to help out with fixing that.
#include <iostream>
#include <string>
using namespace std;
int main()
{
int days;
int date;
int month;
month: // label
cout << "Please enter a number from 1-12 to represent a month: " ;
cin >> month;
switch(month){
case 1:
cout << "January" << endl;
days = 31;
break;
case 2:
cout << "February" << endl;
days = 28;
break;
case 3:
cout << "March" << endl;
days = 31;
break;
case 4:
cout << "April" << endl;
days = 30;
break;
case 5:
cout << "May" << endl;
days = 31;
break;
case 6:
cout << "June" << endl;
days = 30;
break;
case 7:
cout << "July" << endl;
days = 31;
break;
case 8:
cout << "August" << endl;
days = 31;
break;
case 9:
cout << "September" << endl;
days = 30;
break;
case 10:
cout << "October" << endl;
days = 31;
break;
case 11:
cout << "November" << endl;
days = 30;
break;
case 12:
cout << "December" << endl;
days = 31;
break;
default:
cout << "Please enter a valid month: ";
goto month; // loops back if invalid input
}
date: // label
cout << "Please enter a number from 1-" << days << " to represent a date: ";
cin >> date;
switch(date){
case 1:
cout << month << "/1" << endl;
break;
case 2:
cout << month << "/2" << endl;
break;
case 3:
cout << month << "/3" << endl;
break;
case 4:
cout << month << "/4" << endl;
break;
case 5:
cout << month << "/5" << endl;
break;
case 6:
cout << month << "/6" << endl;
break;
case 7:
cout << month << "/7" << endl;
break;
case 8:
cout << month << "/8" << endl;
break;
case 9:
cout << month << "/9" << endl;
break;
case 10:
cout << month << "/10" << endl;
break;
case 11:
cout << month << "/11" << endl;
break;
case 12:
cout << month << "/12" << endl;
break;
case 13:
cout << month << "/13" << endl;
break;
case 14:
cout << month << "/14" << endl;
break;
case 15:
cout << month << "/15" << endl;
break;
case 16:
cout << month << "/16" << endl;
break;
case 17:
cout << month << "/17" << endl;
break;
case 18:
cout << month << "/18" << endl;
break;
case 19:
cout << month << "/19" << endl;
break;
case 20:
cout << month << "/20" << endl;
break;
case 21:
cout << month << "/21" << endl;
break;
case 22:
cout << month << "/22" << endl;
break;
case 23:
cout << month << "/23" << endl;
break;
case 24:
cout << month << "/24" << endl;
break;
case 25:
cout << month << "/25" << endl;
break;
case 26:
cout << month << "/26" << endl;
break;
case 27:
cout << month << "/27" << endl;
break;
case 28:
cout << month << "/28" << endl;
break;
case 29:
cout << month << "/29" << endl;
break;
case 30:
cout << month << "/30" << endl;
break;
case 31:
cout << month << "/31" << endl;
break;
default:
cout << "Invalid date. Please try again: ";
goto date; // loops back if invalid input
}
if (date + 14 > days)
cout << "Two weeks from your selected date is " << (month + 1) << "/" << ((date + 14) - 30) << endl;
else cout << "Two weeks from your selected date is " << month << "/" << (date + 14) << endl;
return 0;
}
So you're taking Computer Science courses in Grade 10. I am taking the Grade 10 course instead of the Grade 11 course based on the recommendations of my GLE/Resource teacher. I am in Grade 11.Stargazing said:ooh i'm currently doing something like this in computer studiesMaria Renard said:Finally finished my third assignment for Turing for Computer Science.
Megumin said:try this (i added comments to things i put in):Jim Perry said:Megumin said:btw this doesnt loop back when you put in an incorrect date/monthJim Perry said:Just wait until the day they assign you something like this (this is in C++, by the way):
Code:#include <iostream> #include <string> using namespace std; int main() { int days; int date; int month; cout << "Please enter a number from 1-12 to represent a month: " ; cin >> month; switch(month){ case 1: cout << "January" << endl; days = 31; break; case 2: cout << "February" << endl; days = 28; break; case 3: cout << "March" << endl; days = 31; break; case 4: cout << "April" << endl; days = 30; break; case 5: cout << "May" << endl; days = 31; break; case 6: cout << "June" << endl; days = 30; break; case 7: cout << "July" << endl; days = 31; break; case 8: cout << "August" << endl; days = 31; break; case 9: cout << "September" << endl; days = 30; break; case 10: cout << "October" << endl; days = 31; break; case 11: cout << "November" << endl; days = 30; break; case 12: cout << "December" << endl; days = 31; break; default: cout << "Please enter a vaild month: " ; } cout << "Please enter a number from 1-" << days << " to represent a date: "; cin >> date; switch(date){ case 1: cout << month << "/1" << endl; break; case 2: cout << month << "/2" << endl; break; case 3: cout << month << "/3" << endl; break; case 4: cout << month << "/4" << endl; break; case 5: cout << month << "/5" << endl; break; case 6: cout << month << "/6" << endl; break; case 7: cout << month << "/7" << endl; break; case 8: cout << month << "/8" << endl; break; case 9: cout << month << "/9" << endl; break; case 10: cout << month << "/10" << endl; break; case 11: cout << month << "/11" << endl; break; case 12: cout << month << "/12" << endl; break; case 13: cout << month << "/13" << endl; break; case 14: cout << month << "/14" << endl; break; case 15: cout << month << "/15" << endl; break; case 16: cout << month << "/16" << endl; break; case 17: cout << month << "/17" << endl; break; case 18: cout << month << "/18" << endl; break; case 19: cout << month << "/19" << endl; break; case 20: cout << month << "/20" << endl; break; case 21: cout << month << "/21" << endl; break; case 22: cout << month << "/22" << endl; break; case 23: cout << month << "/23" << endl; break; case 24: cout << month << "/24" << endl; break; case 25: cout << month << "/25" << endl; break; case 26: cout << month << "/26" << endl; break; case 27: cout << month << "/27" << endl; break; case 28: cout << month << "/28" << endl; break; case 29: cout << month << "/29" << endl; break; case 30: cout << month << "/30" << endl; break; case 31: cout << month << "/31" << endl; break; default: cout << "Invalid date. Please try again: "; } if (date + 14 > days) cout << "Two weeks from your selected date is " << (month + 1) << "/" << ((date + 14) - 30) << endl; else cout << "Two weeks from your selected date is " << month << "/" << (date + 14) << endl; return 0; }
I think you'll like C++.
you should use labels/goto or encompass date/month in a while loop or something if you learned those
make sure you always debug!
Noted. I thought I fixed that but I'll try to hit up my uncle to help out with fixing that.
Code:#include <iostream> #include <string> using namespace std; int main() { int days; int date; int month; month: // label cout << "Please enter a number from 1-12 to represent a month: " ; cin >> month; switch(month){ case 1: cout << "January" << endl; days = 31; break; case 2: cout << "February" << endl; days = 28; break; case 3: cout << "March" << endl; days = 31; break; case 4: cout << "April" << endl; days = 30; break; case 5: cout << "May" << endl; days = 31; break; case 6: cout << "June" << endl; days = 30; break; case 7: cout << "July" << endl; days = 31; break; case 8: cout << "August" << endl; days = 31; break; case 9: cout << "September" << endl; days = 30; break; case 10: cout << "October" << endl; days = 31; break; case 11: cout << "November" << endl; days = 30; break; case 12: cout << "December" << endl; days = 31; break; default: cout << "Please enter a valid month: "; goto month; // loops back if invalid input } date: // label cout << "Please enter a number from 1-" << days << " to represent a date: "; cin >> date; switch(date){ case 1: cout << month << "/1" << endl; break; case 2: cout << month << "/2" << endl; break; case 3: cout << month << "/3" << endl; break; case 4: cout << month << "/4" << endl; break; case 5: cout << month << "/5" << endl; break; case 6: cout << month << "/6" << endl; break; case 7: cout << month << "/7" << endl; break; case 8: cout << month << "/8" << endl; break; case 9: cout << month << "/9" << endl; break; case 10: cout << month << "/10" << endl; break; case 11: cout << month << "/11" << endl; break; case 12: cout << month << "/12" << endl; break; case 13: cout << month << "/13" << endl; break; case 14: cout << month << "/14" << endl; break; case 15: cout << month << "/15" << endl; break; case 16: cout << month << "/16" << endl; break; case 17: cout << month << "/17" << endl; break; case 18: cout << month << "/18" << endl; break; case 19: cout << month << "/19" << endl; break; case 20: cout << month << "/20" << endl; break; case 21: cout << month << "/21" << endl; break; case 22: cout << month << "/22" << endl; break; case 23: cout << month << "/23" << endl; break; case 24: cout << month << "/24" << endl; break; case 25: cout << month << "/25" << endl; break; case 26: cout << month << "/26" << endl; break; case 27: cout << month << "/27" << endl; break; case 28: cout << month << "/28" << endl; break; case 29: cout << month << "/29" << endl; break; case 30: cout << month << "/30" << endl; break; case 31: cout << month << "/31" << endl; break; default: cout << "Invalid date. Please try again: "; goto date; // loops back if invalid input } if (date + 14 > days) cout << "Two weeks from your selected date is " << (month + 1) << "/" << ((date + 14) - 30) << endl; else cout << "Two weeks from your selected date is " << month << "/" << (date + 14) << endl; return 0; }
Baby Luigi said:maybe one day you'll learn how to hack stuff
// NOTES:
// not handling leap year case
// not handling non-integer input (ie: typing in a character like 'a' instead of a number)
// don't ever use goto, it makes the code confusing to read because they can go anywhere and the reader has to keep track of what's happening. Here you just want a loop, so use a loop for clarity's sake.
// uint8_t (which for ease I'm gonna call u8) can give you extra space for no effort. u8's only take up one byte and range from 0 to 255, whereas int is 4 bytes and range of -2147483648 to 2147483647.
// however, std::cin/cout doesn't work well with u8 so you need to use int for that
// get out of the habit of 'using namespace'. This can create problems further down the track if your namespaces/scopes have functions with the same name. This can confuse the compiler and introduce hard-to-track-down bugs. It also makes it clear where that function is defined so anyone reading it can track it down if they have to
// the enum class gives you a meaningful way to represent the numbers 1-12 for your months, while also scoping them and forcing the compiler to represent them as a u8 (only taking one byte). However this is a c++11 feature so if you're not using that then you may need to use regular enums (which are also okay but not as cool as enum classes).
// unfortunately there's no easy way to convert an enum class to a string (one of the major drawbacks of c++) so that's what that switch statement is for
// the anonymous namespace is there to scope DAYS_IN_FORTNIGHT to just this file. again, this is a c++11 feature, which if you're not using you may need to use a static const instead.
// asserts are there to catch programmer error. They're there because that line of code should never be reached and if it does, it means the programmer has done something wrong (eg: the programmer adds 'SMARCH' to the Month list but does not add it to those switch statements, making the assert go off).
// related chunks of code are broken up into functions to make things easier to read
#include <string>
#include <iostream>
#include "assert.h"
namespace {
const int DAYS_IN_FORTNIGHT = 14;
};
enum class EMonth : uint8_t {
JANUARY = 1,
FEBRUARY,
MARCH,
APRIL,
MAY,
JUNE,
JULY,
AUGUST,
SEPTEMBER,
OCTOBER,
NOVEMBER,
DECEMBER,
};
EMonth GetMonthFromInput();
std::string EMonthToString(EMonth month);
int DaysFromMonth(EMonth month);
int GetDaysFromInput(EMonth month);
void PrintDate(EMonth month, int days);
void PrintDateInFortnight(EMonth month, int days);
int main()
{
EMonth month = GetMonthFromInput();
std::cout << EMonthToString(month) << "\n";
int days = GetDaysFromInput(month);
PrintDate(month, days);
PrintDateInFortnight(month, days);
return 0;
}
EMonth GetMonthFromInput() {
int monthInput = 0;
while (true) {
std::cout << "Please enter a number from 1-12 to represent a month: \n";
std::cin >> monthInput;
switch (monthInput) {
case (int)EMonth::JANUARY: return EMonth::JANUARY;
case (int)EMonth::FEBRUARY: return EMonth::FEBRUARY;
case (int)EMonth::MARCH: return EMonth::MARCH;
case (int)EMonth::APRIL: return EMonth::APRIL;
case (int)EMonth::MAY: return EMonth::MAY;
case (int)EMonth::JUNE: return EMonth::JUNE;
case (int)EMonth::JULY: return EMonth::JULY;
case (int)EMonth::AUGUST: return EMonth::AUGUST;
case (int)EMonth::SEPTEMBER: return EMonth::SEPTEMBER;
case (int)EMonth::OCTOBER: return EMonth::OCTOBER;
case (int)EMonth::NOVEMBER: return EMonth::NOVEMBER;
case (int)EMonth::DECEMBER: return EMonth::DECEMBER;
}
std::cout << "Input was invalid, please try again.\n";
monthInput = 0;
}
}
std::string EMonthToString(EMonth month) {
switch (month) {
case EMonth::JANUARY: return std::string("January");
case EMonth::FEBRUARY: return std::string("February");
case EMonth::MARCH: return std::string("March");
case EMonth::APRIL: return std::string("April");
case EMonth::MAY: return std::string("May");
case EMonth::JUNE: return std::string("June");
case EMonth::JULY: return std::string("July");
case EMonth::AUGUST: return std::string("August");
case EMonth::SEPTEMBER: return std::string("September");
case EMonth::OCTOBER: return std::string("October");
case EMonth::NOVEMBER: return std::string("November");
case EMonth::DECEMBER: return std::string("December");
}
assert(false);
return std::string("");
};
int DaysFromMonth(EMonth month) {
switch (month) {
case EMonth::JANUARY:
case EMonth::MARCH:
case EMonth::MAY:
case EMonth::JULY:
case EMonth::AUGUST:
case EMonth::OCTOBER:
case EMonth::DECEMBER:
return 31;
case EMonth::APRIL:
case EMonth::JUNE:
case EMonth::SEPTEMBER:
case EMonth::NOVEMBER:
return 30;
case EMonth::FEBRUARY:
// if leap year
// return 29;
// else
return 28;
}
assert(false);
return 0;
};
int GetDaysFromInput(EMonth month) {
const int DaysInMonth = DaysFromMonth(month);
int days = 0;
while (true)
{
std::cout << "Please enter a number from 1-" << DaysInMonth << " to represent a date: \n";
std::cin >> days;
if (days > 0 && days <= DaysInMonth)
return days;
std::cout << "Input was invalid, please try again.\n";
days = 0;
}
}
void PrintDate(EMonth month, int days) {
std::cout << EMonthToString(month) << "/" << days << "\n";
};
void PrintDateInFortnight(EMonth month, int days) {
int daysInTwoWeeks = days + DAYS_IN_FORTNIGHT;
int daysInMonth = DaysFromMonth(month);
if(daysInTwoWeeks < daysInMonth) {
std::cout << "Two weeks from your selected date is " << EMonthToString(month) << "/" << daysInTwoWeeks << "\n";
return;
}
uint8_t nextMonthU8 = (uint8_t)(month)+1;
if (nextMonthU8 > (uint8_t)EMonth::DECEMBER)
nextMonthU8 = 1;
std::cout << "Two weeks from your selected date is " << EMonthToString((EMonth)nextMonthU8) << "/" << (daysInTwoWeeks - daysInMonth) << "\n";
};
correct, since i know nothing about computer coding i decided to take the grade 10 course. i'm also in grade 10, lmaoMaria Renard said:So you're taking Computer Science courses in Grade 10. I am taking the Grade 10 course instead of the Grade 11 course based on the recommendations of my GLE/Resource teacher. I am in Grade 11.
KPH2293 said:Hi guys, hope everyone is doing well.
I've got a date at 4:30 today with a girl I've been talking to for awhile, so I'm really excited for that.