I need help with this difficult C++ assignment.?

I need help with this difficult C++ assignment.? Topic: Method of assignment writing
June 26, 2019 / By Luanne
Question: Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sunday for Sunday. The program should be able to perform the following operations on an object of type dayType: Step a: Set the day. Step b: Print the day. Step c: Return the day. Step d: Return the next day. Step e: Return the previous day. Step f: Calculate and return the day by adding certain days to the current day. For example, if the current day is Monday and we add 4 days, the day to be returned is Friday. Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday. Step g: Add the appropriate constructors. Write the definitions of the functions to implement the operations for the class dayType.
Best Answer

Best Answers: I need help with this difficult C++ assignment.?

Kay Kay | 1 day ago
Usually, the day would be stored as a number (0-6), So, you'd have methods to convert the name of the day to the number and visa versa. So if you accept that idea, then you have to decide which day of the week (Sunday or Monday) will be day 0. So, the next thing is to use stepwise refinement. Don't try to write the whole program. Start with a small program that can convert the day name into a number. You'll need that number in Step f even if you store the day as its name. Are you asking us to write the whole program for you? ==================== #include using namespace std; class dayType { const string days = "Monday Tuesday Wednesday"; int dayNum; public: void setDay (string); private: int name2num (string); }; void dayType:: setDay (string dayName) { dayNum = name2num (dayName); cout << dayNum << endl; } int dayType:: name2num (string dayName) { cout << dayName << endl; return days.find (dayName) / 9; } int main() { dayType myDay; myDay.setDay ("Wednesday"); return 0; }
👍 130 | 👎 1
Did you like the answer? I need help with this difficult C++ assignment.? Share with your friends

We found more questions related to the topic: Method of assignment writing

Kay Originally Answered: How difficult is to get into FSU?
Daenerys was correct with the requirements for FSU. However, since you are first generation, you might qualify for the summer bridge program. The requirements for the summer bridge program are lower than the ones for general admission.

Holly Holly
#include enum DayOfWeek {SUNDAY, MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY}; const char * const daynames[] = {"Sunday", "Monday", "Tuesday" }; // the rest is for you to do! class dayType { const DayOfWeek m_d; public: dayType(DayOfWeek d): m_d(d){} dayType ahead(int n) const { return static_cast((m_d+n)%7); } dayType tomorrow() const { return ahead(1); } dayType yesterday() const { return ahead(6); } operator DayOfWeek() const { return m_d; } std::string name() const { return daynames[m_d]; } }; int main() { dayType d(MONDAY); std::cout << d.tomorrow().name() << '\n' << d.yesterday().name() << '\n'; DayOfWeek y = SUNDAY; if(y==d.yesterday()){ std::cout << "OK"; } if(MONDAY==dayType(TUESDAY).ahead(13)){ std::cout << "OK"; } return 0; }
👍 50 | 👎 -1

Edana Edana
This is a job for enum and % (modulo) to do math; and an array of strings that are what are printed. Unfortunately I don't know C++. If the hints you've been given aren't enough for you to find examples in your textbook, then you don't know C++ either.
👍 50 | 👎 -3

Chantel Chantel
Do your own homework and make your parents proud.... You wouldn't want them to raise a cheater would you?
👍 50 | 👎 -5

Chantel Originally Answered: Is this too difficult?
no, you can handle it. i have harder classes and i am a junior. i have IB classes which is higher than AP and i also have to write a 15 page paper on a topic of my choice, and do 150 hours of community service. however, if i attain my diploma, it will be recognized worldwide no matter where i go.

If you have your own answer to the question method of assignment writing, then you can write your own version, using the form below for an extended answer.