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]
4 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]4 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
in python Write a loop that counts the number of lowercase characters that appear in the string referenced by mystring.
exis [7]

Answer:

mystring = "My name is David Acheme"

count = 0

for i in mystring:

    if(i.islower()):

        count=count+1

print("The number of lowercase characters in: "+mystring)

print(count)

Explanation:

1. We declare a String Variable and assign a value.

2. Intialize a count variable to zero.

3. Using a for loop is to loop through each characters in the string.

4. The if condition checks when a lower case character is encountered using the islower method and increases count by 1

5. Prints the value of count.

5 0
4 years ago
Bob is having no luck performing a penetration test on Retail Store's network. He is running the test from home and has download
Novosadov [1.4K]

Incomplete question. The full question read;

Why is Jim having these problems?

Options:

A. Security scanners are not designed to do testing through a firewall.

B. Security scanners cannot perform vulnerability linkage.

C. Security scanners are only as smart as their database and cannot find unpublished vulnerabilities.

D. All of the above.

Answer:

<u>D. All of the above.</u>

Explanation:

<em>Remember, </em><u>security scanners</u> are only designed to <em>gather</em> information about a network, but not with the ability to perform firewall testing. Also, these security scanners are pre-programmed with existing vulnerabilities in their database, and so it would impossible to discover vulnerabilities on the Retail store's network.

Hence, since Bob is using the wrong tools, he is unsuccessful in performing a penetration test.

3 0
3 years ago
A systems engineer suspects a new type of malware has impacted the company network. Which threat hunting approach does the engin
Vlad [161]

Answer:

Analyze network traffic

Identify the method of execution

Explanation:

Threat Hunting is a form of cybersecurity strategy carefully formulated to recognize threats that are yet to be found by routine security monitoring.

Using the approach of Threat hunting means applying unconventional techniques to determine the threats or find the origin of the malware.

Hence, in this case, the system engineer should carry out the following steps:

1. Analyze network traffic

2. Identify the method of execution

3 0
3 years ago
Mike wants to build an amplifier. which technology can he use?
STatiana [176]
A.
Not B because a guitar has no moving parts.
Not C because guitars receive all the power they need from a cord.
And not D because a guitar is not a car and doesn't need to move!
4 0
3 years ago
What can you hold in your left hand but not in your right? for creese7911 and maranda66
Drupady [299]

Answer:

You're right hand or Left too

Explanation:

Because some people can hold some stuff on there hands

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which is NOT a way the network operating sys-
    6·1 answer
  • An HP PC does not support the HP System Board Configuration tool, and you must use the HP System Board Replacement and System Di
    7·1 answer
  • How to cite a website, like asha.org?
    6·1 answer
  • What is sfa software?
    10·1 answer
  • A user who has special security and access to a system, such as the right to assign passwords, is called a ____.​ a. ​ technical
    8·1 answer
  • Declare a Scanner reference variable fileInput, and assign it a newly created Scanner object that is associated with a file name
    10·1 answer
  • When you see ####### in a cell, you should​
    11·1 answer
  • DigitalHealth Electronics Inc. is a company that builds diagnostic devices. It was the first company to develop a compact MRI sc
    13·1 answer
  • Ple Choice Worth 5 points)
    11·1 answer
  • Can people survive without technology?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!