EBK C++ PROGRAMMING: FROM PROBLEM ANALY
8th Edition
ISBN: 8220103648530
Author: Malik
Publisher: Cengage Learning US
expand_more
expand_more
format_list_bulleted
Question
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.
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
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 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 the class Day that implements the day of the week in a program. The program should be able to perform the following operations on an object of the type Day:
Set the day.
Print the day.
Return the day.
Return the next day.
Return the previous day.
Add a comment with your full name in it in any part of the program.
Chapter 10 Solutions
EBK C++ PROGRAMMING: FROM PROBLEM ANALY
Ch. 10 - Mark the following statements as true or false....Ch. 10 - Find the syntax errors in the following class...Ch. 10 - Find the syntax errors in the following class...Ch. 10 -
Find the syntax errors in the following class...Ch. 10 -
Find the syntax errors in the following class...Ch. 10 - Prob. 6SACh. 10 - Assume the definition of class foodType as given...Ch. 10 -
Consider the definition of the following class:...Ch. 10 - Consider the definition of the class product Type...Ch. 10 -
Consider the definition of the class product Type...
Ch. 10 - Prob. 11SACh. 10 -
Assume the definition of class houseType as given...Ch. 10 - Chapter 9 defined the struct studentType to...Ch. 10 - Write a program that uses the class productType...Ch. 10 -
Write a program that uses the class houseType...Ch. 10 - Prob. 6PECh. 10 - Prob. 7PECh. 10 - Some of the characteristics of a book are the...Ch. 10 - Define the class bankAccount to implement the...
Knowledge Booster
Similar questions
- Using JAVASCRIPT write an object prototype for a Person that has a name and age, has a printInfo method, and also has a method that increments the persons age by 1 each time the method is called. Create two people using the 'new' keyword, and print both of their infos and increment one persons age by 3 years. Use an arrow function for both methods */ // Create our Person Prototype // Use an arrow to create the printInfo method // Create another arrow function for the addAge method that takes a single parameter // Adding to the agearrow_forwardCreate the following class diagram: The print method in: - Author prints the Authors data - Page prints page no and text - Textbook prints the subject and all pages - Novel prints the genre and all pages The toString method in: - Book returns title and authors - textbook returns subject in additions to super toString - Novel genre in additions to super toString Test your implementation create objects of different types example : - Create a book of type Novel which has many pages and several authors - Create a book of type Textbook which has many pages and several authors - Access these objects polymorphically, variable of class book contains objects of its subclasses Textbook and novel - Print a hall book - Print a single page of a book - Print the book and its authorsarrow_forwardjava languageCreate a class with following attributes: The car's make The car's model The car's year Now let's identify the class's methods. Specifically, the actions are: Constructor of Car class Set and get the car's make Set and get the car's model Set and get the car's year Now create few instance of the Car in a Test class. Use getter and setter to set the instance variables. Create a class with following attributes: The car's make The car's model The car's year Now let's identify the class's methods. Specifically, the actions are: Constructor of Car class Set and get the car's make Set and get the car's model Set and get the car's year Now create few instance of the Car in a Test class. Use getter and setter to set the instance variables.arrow_forward
- This is the tester of two classesarrow_forwardPlease do it in JavaScript or C# 1) Design and implement the class structure for a drawing application. A drawing is made up of a canvas that contains a collection of three different shapes: circles, lines, and boxes. Each shape can be drawn by calling a Draw() method for that shape. The canvas class should also have a draw method that draws all of the shapes it contains. You don’t have to actually draw anything on a screen; you can simulate drawing by writing a message to the console.For example, the code snippet: canvas.Draw();Drawing a circle at...Drawing a line at...etc. (For each shape on the canvas) 2)(Bonus) Consider re-writing the above answer (#1) differently where the canvas does not contain the shapes, but is able to draw any of the three shapes passed to it. Re-design canvas.Draw() if you need to. Your main() program should ask for user input on what shape to draw. Ask once, draw, then exit.could produce something like the following output to the console:arrow_forwardJAVA Task Write a JAVA class named Account to represent an account that you may find at a bank. Accounts have a balance and an annual interest rate. Include attributes in the Account class to reflect these. Write getters for both attributes and a setter for only the annual interest rate. Think about how real bank accounts work, you change your balance by withdrawing and depositing money, not just by telling the banker how much you want to change it to. Include a constructor with parameters used to assign values to both attributes. Users should be able to withdraw money from an Account, deposit money into an Account, find monthly interest rate, and find monthy interest. Include methods for each of these actions. More details on them below. withdraw method This method simulates withdrawing money from the Account. It should not return a value and take the amount to withdraw as a parameter and reduce the balance by this amount. deposit method This method simulates depositing money into…arrow_forward
- Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwisearrow_forwardDesign a class named Rectangle to represent a rectangle. The class must have the following: • double data fields named width and height. The default values are 1 for both width and height A no-argument constructor that creates a default bag. A constructor that creates a rectangle with the specified width and height A getParameter() method to return the perimeter. • A getArear() method to return the area of the Rectangle. Create two Rectangle objects. One with width 4.0 and height 10.0. The other object has width 6.3 and height 10.5.arrow_forwardRectangle Object Monitoring Create a Rectangle class that can compute the total area of all the created rectangle objects using static fields (variables). Remember that a Rectangle has two attributes: Length and Width. Implement the class by creating a computer program that will ask the user about three rectangle dimensions. The program should be able to display the total area of the three rectangle objects. For this exercise, you are required to apply all OOP concepts that you learned in class. Sample output: Enter Length R1: 1 Enter Width R1: 1 Enter Length R2: 2 Enter Width R2: 2 Enter Length R3: 3 Enter Width R3: 3 The total area of the rectangles is 14.00 Note: All characters in boldface are user inputs.arrow_forward
- PYTHON: Define the Artist class with a constructor to initialize an artist's information and a print_info() method. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. print_info() should display Artist Name, born XXXX if the year of death is -1 or Artist Name (XXXX-YYYY) otherwise. Define the Artwork class with a constructor to initialize an artwork's information and a print_info() method. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor parameter values. Ex: If the input is: Pablo Picasso 1881 1973 Three Musicians 1921 the output is: Artist: Pablo Picasso (1881-1973) Title: Three Musicians, 1921 If the input is: Brice Marden 1938 -1 Distant Muses 2000 the output is: Artist: Brice Marden, born 1938 Title: Distant Muses, 2000 I have the code but I am getting errors that I can't seem to get rid of any suggestions would be appreciatedarrow_forward#this is a python programtopic: operation overloading, Encapsulation please find the attached imagearrow_forwardJAVA PROGRAMMING Write two java files for this assignment: Circle.java, and Main.java. The Circle.java file will create an actual class. The Circle class: MEMBER VARIABLE double radius double x double y Eight methods: Six of the methods are simple: getter’s and setter’s for x, y, and radius. There should also be a getArea method that returns the area (derived from the radius) A doesOverlap method. This method should accept a Circle as an argument, and return true if this circle overlaps the circle that the method was invoked on. [Note: two circles overlap if the sum of their radius' is greater than or equal to the distance between their centers.] void setX(double value) double getX() void setY(double value) double getY() void setRadius(double value) double getRadius() double getArea() boolean doesOverlap(Circle otherCircle) second class will be the typical replit Main class, with its static main method .It should contain code that tests the Circle class. submit code that…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781305480537Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning