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
Anna007 [38]
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 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.
Computers and Technology
1 answer:
olya-2409 [2.1K]3 years ago
8 0

#include<iostream>

#include<string>

usingnamespace std;

void menu(); //declartion of function to show the menu

classdayType//creating the class

{

      string Wdays[7];

      int i;

      string day;

      string prDay;

      string NxtDay;

      string AddDays;

public:

      dayType(string);//constructor with one parameter

      string setday(); //declartion of function to set the day

      string preday(); // declartion of function to find privious day

      void Nextday(); // declartion of function to find Next day

      string add(int n); // declartion of function to find after addingthenumber of days given by the user

      void print(); // declartion of function to print the result

};

int main()

{

      int n;

      string d;

      menu(); //displaying menu

      cout <<"Enter the day :";

      getline(cin, d); //Takes the day from the user

      dayType Da(d); //creating an object of a class

      Da.setday();

      Da.preday();

      Da.Nextday();

      cout <<"Enter the No. of days to add :";

      while (!(cin >> n) ||n<0) { //validation checking

                    cin.clear();

                    cin.ignore(999, '\n');

                    cout <<"Invalid data type! \nPlease enter No. of daysto add again :";

             

      }

      Da.add(n);

      Da.print();

      system("pause");

      return 0;

}

dayType::dayType(stringi) :day(i){ //Defintion of a constructor with one parameter

      Wdays[0] = "Mon";

      Wdays[1] = "Tues";

      Wdays[2] = "Wednes";

      Wdays[3] = "Thurs";

      Wdays[4] = "Fri";

      Wdays[5] = "Satur";

      Wdays[6] = "Sun";

}

stringdayType::setday() //Function to set the day

{

      if (day == Wdays[0])

      {

             i = 0;

      }

      elseif (day == Wdays[1])

      {

             i = 1;

      }

      elseif (day == Wdays[2])

      {

             i = 2;

      }

      elseif (day == Wdays[3])

      {

             i = 3;

      }

      elseif (day == Wdays[4])

      {

             i = 4;

      }

      elseif (day == Wdays[5])

      {

             i = 5;

      }

      elseif (day == Wdays[6])

             i = 6;

      else

      {

             day = "Invalid Input";

             i = 7;

      }

      return day;

}

stringdayType::preday() //Function to find the preivous day

{

      if (i == 0)

             prDay = Wdays[6];

      elseif (i == 7)

             prDay = "Invalid Input";

      else

             prDay = Wdays[i - 1];

      return prDay;

}

voiddayType::Nextday() //Function to find Next day

{

      if (i == 6)

             NxtDay = Wdays[0];

      elseif (i == 7)

             prDay = "Invalid Input";

      else

             NxtDay = Wdays[i + 1];

}

stringdayType::add(intn) // function to find after adding the number of days given by the user

{

      n = n + i;

      while (n>= 7)

      {

             n = n - 7;

      }

      if (i == 7)

             Wdays[n] = "Invalid Input ";

      return AddDays = Wdays[n];

}

voiddayType::print()

{

      cout << endl <<"\tDay="<< day <<"day"<< endl;

      cout <<"\tPrevious day :"<< prDay <<"day"<< endl;

      cout <<"\tNext day :"<< NxtDay <<"day"<< endl;

      cout <<"\tAfter Adding Days :"<< AddDays <<"day"<< endl;

}

void menu() //Function to display menu

{

      cout <<"******************MENU********************"<< endl;

      cout <<"\tEnter 'Sun' for 'Sunday'"<< endl;

      cout <<"\tEnter 'Mon' for 'Monday'"<< endl;

      cout <<"\tEnter 'Tues' for 'Tuesday'"<< endl;

      cout <<"\tEnter 'Wednes' for 'Wednesday'"<< endl;

      cout <<"\tEnter 'Thurs' for 'Thursday'"<< endl;

      cout <<"\tEnter 'Fri' for 'Friday'"<< endl;

      cout <<"\tEnter 'Satur' for 'Saturday'"<< endl;

You might be interested in
Which is true about POP3 and IMAP for incoming email?
IceJOKER [234]
<h2>Answer:</h2>

Option A: Both POP3 and IMAP  keep email on an email server by default.

is the correct answer.

<h2>Explanation:</h2>

Following points will make the idea of POP3 and IMAP clear:

<h3>POP3:</h3>
  • POP3  is the acronym for Post Office Protocol 3.
  • POP3 is the method of receiving emails in which the emails received on the app can be downloaded on to the computer by having an internet connection.
  • These downloaded emails can be viewed offline whenever needed and managed as well.
  • POP3 makes it possible that the storage space of the default server do not run short as the downloaded emails are deleted from the server.
<h3>IMAP:</h3>
  • IMAP stands for Internet Message Access Protocol.
  • It is the method in which the mails are viewed and managed directly on the internet server instead of downloading them on the computer.
  • IMAP makes sure to manage the mails so carefully and timely so that unimportant mails are deleted to make sure that the storage space does not run short.
<h3>Conclusion:</h3>

So from these points we can make sure that both ways keep emails on email server but POP3 have option to download mails from server while IMAP dont have.

<h2>I hope it will help you!</h2>
8 0
3 years ago
What are the coordinates of the origin point? (Select the best answer.)
siniylev [52]

Answer:

1,10

Explanation:

7 0
3 years ago
What are movies filmed before 1990's?
natita [175]

Answer: Once Upon a Time in the West (1968) PG-13 | 165 min | Western. ...

Cinema Paradiso (1988) R | 155 min | Drama. ...

Blade Runner (1982) R | 117 min | Action, Sci-Fi, Thriller. ...

2001: A Space Odyssey (1968) G | 149 min | Adventure, Sci-Fi. ...

Apocalypse Now (1979) ...

Chinatown (1974) ...

Stardust Memories (1980) ...

Le Notti Bianche (1957)

Explanation:

8 0
2 years ago
A voltage measurement error is caused by the integration time window of a digital volt-meter. This is a _____________error.
gladu [14]

Answer: Systematic error

Explanation:

  The systematic error is the type of error which is basically caused due to the integration time of the digital volt meter in the voltage error measurement.

It is one of the type of error that occur during the measurement of the voltage due to mismatch start channel. It basically result into the difference between the fall and rise in channel and the difference in the propagation delay.

The systematic error is basically introduce by interconnect different types of cable and setting the triggering level in the system. This type of error are constant in the given measurement configuration process.

4 0
3 years ago
Write a script that creates and calls a stored procedure named test. This procedure should use a transaction that includes the s
natita [175]

Answer:

Check the explanation

Explanation:

use `my_guitar_shop`;

#delete the procedure test if it exists.

DROP PROCEDURE IF EXISTS test;

DELIMITER //

CREATE PROCEDURE test ()

BEGIN

   #declare variable sqlerr to store if there is an sql exception

  declare sqlerr tinyint default false;

   #declare variable handler to flag when duplicate value is inserted

  declare continue handler for 1062 set sqlerr = TRUE;

   #start transaction

   start transaction;

  delete from order_items where order_id in

      (select order_id from orders where customer_id=6);

  delete from orders where customer_id=6;

  delete from addresses where customer_id=6;

  delete from customers where customer_id=6;

 

   if sqlerr=FALSE then

      commit;

        select 'Transaction Committed' as msg;

  else

       rollback;

       select 'Transaction rollbacked' as msg;

   end if;

end //

delimiter ;

call test();

8 0
3 years ago
Other questions:
  • A boolean variable named rsvp an int variable named selection, where 1 represents "beef", 2 represents "chicken", 3 represents "
    14·1 answer
  • Why is driving a privilege?
    15·2 answers
  • In Microsoft Word, spelling errors are identified by a _____.
    5·2 answers
  • What is Processor to Memory Mismatch problem?
    15·1 answer
  • PLEASE HELP ME ANSWER AS MUCH AS YOU CAN I ONLY HAVE 3 POINTS LEFT AND IM TIMED. PLEASE TELL ME THE NUMBER AND LETTER. THANK YOU
    5·1 answer
  • Explain the difference between true north and magnetic north.
    9·1 answer
  • Is the following statement TRUE or FALSE?
    9·1 answer
  • What is the CSS property used to style text as all lowercase or uppercase?
    14·2 answers
  • Difrent between computer and computer system​
    9·1 answer
  • What will be the value of x after the following loop terminates?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!