1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Licemer1 [7]
2 years ago
11

Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, s

uch as Sun for Sunday.
The program should be able to perform the following operations on an object of type dayType:

a) set the day
b) print the day
c) return the day
d) return the next day
e) return the previous day
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.
g) add the appropriate constructors.

Write the definitions of the functions to implement the operations for the class dayType. Also write a program to test various operations on this class.
Computers and Technology
1 answer:
Afina-wow [57]2 years ago
4 0

The code is implemented based on the given operations.

Explanation:

#include <iostream>

#include <string>

using namespace std;

class dayType

{ private:

 string day[7];

 string presentDay;

 int numofDays;

public:

 void setDay(string freshDay);

 void printDay() const;

 int showDay(int &day);

 int nextDay(int day);

 int prevDay(int day) const;

 int calcDay(int day, int numofDays);    

 dayType()

 {

  day[0] = "Sunday";

  day[1] = "Monday";

  day[2] = "Tuesday";

  day[3] = "Wednesday";

  day[4] = "Thursday";

  day[5] = "Friday";

  day[6] = "Saturday";

  presentDay = day[0];

  numofDays = 0;

 };

 ~dayType();

};

#endif

#include "dayType.h"

void dayType::setDay(string freshDay)

{

  presentDay = freshDay;

}

void dayType::printDay()

{

  cout << "Day chosen is " << presentDay << endl;

}

int dayType::showDay(int& day)

{

  return day;

}

int dayType::nextDay(int day)

{

day = day++;

if (day > 6)

 day = day % 7;

switch (day)

{

case 0: cout << "The successive day is Sunday";

 break;

case 1: cout << "The successive day is Monday";

 break;

case 2: cout << "The successive day is Tuesday";

 break;

case 3: cout << "The successive day is Wednesday";

 break;

case 4: cout << "The successive day is Thursday";

 break;

case 5: cout << "The successive day is Friday";

 break;

case 6: cout << "The successive day is Saturday";

 break;

}

cout << endl;

return day;

}

 

int dayType::prevDay(int day)

{

day = day--;

switch (day)

{

case -1: cout << "The before day is Saturday.";

 break;

case 0: cout << "The before day is Saturday.";

 break;

case 1: cout << "The before day is Saturday.";

 break;

case 2: cout << "The before day is Saturday.";

 break;

case 3: cout << "The before day is Saturday.";

 break;

case 4: cout << "The before day is Saturday.";

 break;

case 5: cout << "The before day is Saturday.";

 break;

default: cout << "The before day is Saturday.";

}

cout << endl;

return day;

}

int dayType::calcDay(int addDays, int numofDays)

{

addDay = addDays + numofDays;

if (addDay > 6)

 addDay = addDay % 7;

switch(addDay)

{

case 0: cout << "The processed day is Sunday.";

 break;

case 1: cout << "The processedday is Monday.";

 break;

case 2: cout << "The processedday is Tuesday.";

 break;

case 3: cout << "The processedday is Wednesday.";

 break;

case 4: cout << "The processedday is Thursday.";

 break;

case 5: cout << "The processedday is Friday.";

 break;

case 6: cout << "The processedday is Saturday.";

 break;

default: cout << "Not valid choice.";

}

cout << endl;

return addDays;

}

You might be interested in
As a prospective student, what is the best reason to request an interview with your college application?
weqwewe [10]

Answer: The correct answer is A. I just answered this question myself!

6 0
2 years ago
To whom the script most important
baherus [9]
The scripter as he made the script.
5 0
3 years ago
Write a function named initialMatch that takes a string parameter, text, that contains only lowercase letters and whitespace. Th
Furkat [3]

Answer:

Implementing on Python for the question, the following is the code.

Explanation:

def intialMatch(l):

   word_dict={}

   for word in l.split():

       if word_dict.get(word)==None:

           word_dict[word]=[]

       for key in word_dict.keys():

           if key[0]==word[0] and (word is not key) :

               values = word_dict.get(key)

               if word not in values:

                   values.append(word)

       for key,values in word_dict.items():

           for value in values:

               if value==key:values.remove(value)

   return word_dict

t='do what you can with what you have'

print(intialMatch(t))

6 0
2 years ago
"You are on a service call to fix a customer’s printer when she asks you to install a software package. The software is on a per
pickupchik [31]

Answer:

Ask her to get a genuine software

Explanation:

if i will install, it can cause the following problems:

1. Prated software makes your system Vulnerable to the security attacks because the activities of the software are not monitored by any organization and no one is responsible for anything bad happened to your system.

2. It may stop working anytime because there would not be maintenance patches available for it so that it can work properly.

3. It cannot be updated and may cause problems in core functionalities of it.

4.Serious legal actions can be taken against anyone using them because  economy has drastic decrease due ti use of it.

7 0
2 years ago
Which access object cannot be used to enter or edit data
kap26 [50]

Answer:

Should be B. table !

6 0
1 year ago
Read 2 more answers
Other questions:
  • What do you call the combination of title, description, tags, and thumbnail?
    6·1 answer
  • To create a chart you need to select at least ___ in a range of data
    15·1 answer
  • What three steps Name a group??
    14·1 answer
  • A network host with an IP address of 192.168.10.200 wants to send a message to a destination computer with an assigned IP addres
    6·1 answer
  • Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one.
    11·1 answer
  • The ______ printers are the most popular type of printer in small office/home office and large office environments.
    5·1 answer
  • Kyra is teaching a photography class. She would like her students to share photos. She would also like the students to be able t
    6·1 answer
  • ABC IF U HAVE A LEGENDARY PET ON ADOPT ME OR ANYTHING COOL!! &lt;3
    5·2 answers
  • If an occupation is projected to decline by 7% over the next 10 years, how would you rate the job outlook? (6 points)
    14·1 answer
  • Who know's web Design
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!