C++ Programming: From Problem Analysis to Program Design
C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
Question
Book Icon
Chapter 10, Problem 7PE
Program Plan Intro

Program Plan:

  • Declare a class dayType to store a day and to check the day number is valid or not. If it is valid, then go to the next function. Otherwise print the message "Day number should be in between 0 and 6."
  • Implement the main function that tests all constructors and functions in the class dayType.
  • Implement set function that accepts a day as a parameter then verifies whether the day is valid and sets that day as the current day.
  • Implement print function that accepts a day as an integer parameter and displays that day as a string.
  • Implement getDay function that returns the current day as an integer.
  • Implement next_day function that returns the next day to the current day as an integer.
  • Implement prev_day function that returns the previous day to the current day as an integer.
  • Implement a default constructor that sets 0 to the current day as Sun (Sunday).
  • Implement parameterized constructor that sets the specified day to the current day.

Program Description: The purpose of the program is to implement the days of the week. It stores the day such as Sunday and it performs the specified operations.

Blurred answer
Students have asked these similar questions
Design and implement a class dayType that implements the day of the week in a program. The classdayType should store the day, such as Sun for Sunday. The program should be able to perform thefollowing 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.The class dateType was designed to implement the date in a program, but the member function setDateand the constructor do not check whether the date is valid before storing the date in the member variables.Rewrite the definitions of the function setDate and the constructor so that the values for the month, day,and year are checked before storing the date into the…
Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such as Sun for Sunday. The program should be able to perform the following operations on an object of type dayType: Set the day. a. b. Print the day. Return the day. c. d. Return the next day. Return the previous day. е. 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. f. g. Add the appropriate constructors. Write the definitions of the functions to implement the operations for the class dayType as defined in Programming Exercise 5. Also, write a program to test various operations on this class. Code for dayType class: class dayType { public: static string weekDays[7]; void print() const; string nextDay) const; string prevDay() const; void addDay(int nDays);…
Design and implement a class dayType that implements the day of the week in a program. The class dayType should store the day, such 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.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT