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
Given two int variables , firstplacewinner and secondplacewinner, write some code that swaps their values . declare any addition
Mekhanik [1.2K]
Int tmp;
tmp = firstplacewinner;
firstplacewinner = secondplacewinner;
secondplacewinner = tmp;
5 0
2 years ago
4
madam [21]

Answer:

its the basic link

Explanation:

6 0
2 years ago
Read 2 more answers
Uhaul general mechanical questions 2021
hammer [34]

Moving or transportation tools, equipment and methods provides guidance

on the safe an efficient ways to move items.

The correct responses are;

1) (B); 2) B; 3) C; 4) A; 5) D; 6) B; 7) A; 8) B; 9) (A); 10) A; 11) C; 12) B; 13) A; 14) A; 15) B; 16) A; 17) B; 18) A; 19) (C); 20) B; 21) B; 22) A; 23) B; 24) (C); 25) B

Reasons:

1) The correct option is; (B) Withstand a heavier load and add greater stability

  • By sing two wheels on the rear of a truck, heavy loads can be hauled, and transported around corners, and bumpy roads, reducing the possibility of the load tipping the truck over, thereby keeping the truck stable.

2) The correct option is; B

  • The Phillips-head screw is cross shaped, and required a cross shaped screwdriver, which is option B)

3) The correct option is; C

  • The alternator converts mechanical rotational energy into electrical energy, and usually has a compact electrical coil and magnets within its enclosure. The alternator is option C

4) The correct option is; A

  • The rear of a truck moves in the direction the front tires are turned

5) The correct option is; D

  • Option A  and B are pliers, while option B is a spanner, all of which are used to fasten and loosen bolts and nuts. Option D is a screwdriver used to fasten and loosen screws.

6) The correct option is; B

  • The working platform on scaffold B has extra support from the diagonal braces.

7) The correct option is; A

  • The large size tires in refrigerator A increases the contact surface with the road to prevent entering into small holes

8) The correct option is; B

  • Due to the heavier load in the trailer of pick-up truck B, more force is required, to stop the truck according to Newton's Laws of motion, and therefore, a longer distance will be taken to stop by the truck, given similar conditions (magnitude) stopping force available

9) The correct option is; (A)

  • Jumping two batteries to start an automotive with a dead battery requires a Negative to Negative / Positive to Positive  connection, which is option (A)

10) The correct option is; A

  • The air filter will have a open outer rim for the free passage of air.

11) The correct option is; C

  • The scale measures the difference in weight, and the weight depends on the mass of the item. Given that the mass are equal, both weights would be equal, and therefore, the scale would be level.

12) The correct option is; B

  • The smoothest ride is closest to the most weight of the vehicle, which is located in the front, therefore, the area that gets the smoothest ride is option B

13) The correct option is; A

  • The downward pressure is given by the location of the load relative to the wheel on the trailer, that gives either a clockwise or downward moment of force when in position of option A or a counterclockwise or upward moment at B

14) The correct option is; A

  • Gear connected by belt or chain move in the same direction, therefore, the direction of wheel 3 is option A

15) The correct option is; B

  • A tire blowout will not occur because, the pressure is below the recommended pressure. However, the motion of the car will be unstable

16) The correct option is; A

  • When tightening a nut with an adjustable wrench, the direction of turning the wrench is towards the movable jaw, therefore, the option A is correct

17) The correct option is; B

  • The difference between the threads of the given tires is the depth of their grooves, therefore, the tire in option B has more thread.

18) The correct option is; A

  • When loading items on a trailer, the majority of the load should be located in the front, therefore, the correct location for loading only the washer is illustrated by the picture A.

19) The correct option is; (C)

  • The object has a lead, an insulated handle, and a electrical bulb that lights up when there is electricity, therefore, it is used for (C) Checking for electrical current travelling through a wire.

20) The correct option is; B

  • The trailer swings in the opposite direction to the truck.

21) The correct option is; B

  • The ladder in picture B is safer because it spreads more at the base

22) The correct option is; A

  • Most of the weight of the refrigerator act on the wheel in picture A than in picture B

23) The correct option is; B

  • The gear turns towards the screen on the left and away from the screen on the right, which is a direction from left to right.

24) The correct option is; (C)

  • The cotter pin is assembled last to hold the bolt in place, and cannot be assembled before the other parts as it will restrict their movement

25) The correct option is; B

The front tire should be turned in the opposite direction to the intended direction of the trailer.

Learn more here:

brainly.com/question/69628

6 0
2 years ago
Please help i really need to turn this in already
Step2247 [10]

V = √P*R

RED

It doesn't really do anything active wise but it is used to reduce current flows, adjust signal levels, and to divide voltage.

7 0
3 years ago
Wirte a program which asks the users to input length and calculates the area of a square.( Area = Length^2)​
kogti [31]

Explanation:

i hope this will help you

3 0
2 years ago
Other questions:
  • Write the interface (.h file) of a class ContestResult containing: An data member winner of type string, initialized to the empt
    14·1 answer
  • To change to the completed application’s directory, we opened a command window and used the ________ command to change to the di
    7·1 answer
  • While you are working with a document using a program such as wordpad, the document is stored in ___________?
    15·2 answers
  • Can someone help me to give this guy brainliest the button is not there
    8·1 answer
  • "When you can control devices and appliances by apps installed on your smartphone or tablet, you are said to have"
    6·1 answer
  • For which type of long-distance call do you need to tell the operator the name of the person to whom you wish to speak?
    10·1 answer
  • A server of service is responsible for sending the contents of cengage.com to your browser when you type cengage.com into the lo
    12·1 answer
  • Encrypting text allows us to encrypt and decrypt the text using a special key.
    9·1 answer
  • What is the output of the following program? If there is any problem, how can
    13·1 answer
  • How many pages is 1500 words double spaced 12 font?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!