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]
3 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]3 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
What command is used to generate an RSA key pair?
Leokris [45]

Answer:

D) crypto key generate rsa

Explanation:

In cryptography, the RSA refers to Rivest–Shamir–Adleman. This is an algorithm used for encrypting and decrypting messages in computers thereby ensuring secured transmission of data. In order to generate an RSA key pair, you will use the command crypto key generate rsa while in the global configuration mode. This command has the following syntax:

crypto key generate rsa [general-keys| usage-keys| signature| encryption] [<em>labelkey-label</em>] [exportable] [modulus <em>modulus-size</em>] [storage <em>name of device</em>:][redundancy][on <em>name of device</em>:],

with each parameter having its description

5 0
3 years ago
if someone has become very attached to their mobile device and feels anxious if the cannot connect to the internet, what are the
svp [43]

Answer:

Anxiety

Explanation:

trust I have it

4 0
3 years ago
Why do we allow electronic instruments to warm up before use?
son4ous [18]
Is not really a warm up!

we wait for the computer (electronic instrument) to load or process all the data in order to operate properly as its supposed to!
3 0
3 years ago
!WILL GIVE BRAINLIEST!
balandron [24]

Answer:

word = input()

if word > "apple" and word < "pear":

   print("Word is valid.")

else:

   print("Word is out of range.")

3 0
3 years ago
1.- Make a program that loops and perform powers of 5 on each loop.
Olin [163]

A program that loops and performs powers of 5 on each loop.In each lap the operator is asked IN CODE C++ the C++ Program for the given hassle announcement is as follows:#include the use of namespace std.

<h3>What is the energy of a variety of?</h3>

The energy of a variety of says how usually to apply the range in a multiplication. Powers also are known as Exponents or Indices. For example, eight^2 might be known as “eight to the energy 2” or “eight to the second one energy”, or simply “eight square.

  1. C++ Program for the given hassle announcement is as follows:
  2. #include
  3. the use of namespace std;
  4. int main() > base;
  5. cout << "nEnter the exponent: ";     //asks the user for keyboard input for exponent
  6. cin>>exponent;
  7.  for (int i = 1; i <=exponent; i++)    //iterate {through|thru|via">via 1 until exponent
  8. {
  9.       num=num*base;
  10. //base is multiplied (e.g. 2*2*2.....n) until n, wherein n is exponent
  11.    }
  12. cout <<"n"<strength of "<go back 0;
  13. }
  14. Sample Output:
  15. Stdin Inputs

Read more about the loops :

brainly.com/question/26497128

#SPJ1

6 0
2 years ago
Other questions:
  • Create a class named BaseballGame that contains data fields for two team names and scores for each team in each of nine innings.
    12·1 answer
  • Computer hardware had been designed to run a single operating system and a single app, leaving computers vastly underutilized. o
    15·1 answer
  • What is the command to use the memory diagnostics tool?
    11·1 answer
  • Due to the absorption and scattering of shorter wavelengths by interstellar dust, distant stars appear A) bluer. B) brighter. C)
    9·1 answer
  • Alpha Technologies, a newly established company, wants to share information about its work with people all over the world. Which
    9·1 answer
  • Implement a java program to find the smallest distance between two neighbouring numbers in an array.
    7·1 answer
  • What is another term for accountability?
    7·2 answers
  • What is the definition of digital literacy?
    7·2 answers
  • Which of the following is NOT necessary for organizing data to make it easier to sort?
    6·1 answer
  • 2 Manter o autocontrole nos ajuda a evitar muitos problemas na nossa vida pessoal e no ambiente profissional. Em se tratando de
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!