Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 5, Problem 8PP

Complete the previous Programming Project and create a top-level function named dayOfWeek with the header:

  int dayOfWeek(int month, int day, int year);

The function should encapsulate the necessary logic to return the day of the week of the specified date as an int (Sunday = 0, Monday = 1, etc.) You should add validation code to the function that tests if any of the inputs are invalid. If so, the function should return –1 as the day of the week. In your main function write a test driver that checks if dayOfWeek is returning the correct values. Your set of test cases should include at least two cases with invalid inputs.

Blurred answer
Students have asked these similar questions
The Issue: You have a function that accepts a variety of parameters. It is impractical to provide them as traditional parameters. So, what are you going to do?
The following formula can be used to determine the distance an object falls due to gravity in a specific time period: d = 1⁄2 gt2The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the time in seconds that the object has been falling. Write a function named fallingDistance that accepts an object’s falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Write a program that demonstrates the function by calling it in a loop that passes the values 1 through 10 as arguments and displays the return value.
USE C++programming language

Chapter 5 Solutions

Problem Solving with C++ (9th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
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
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Python - bracket parenthesis and braces; Author: MicroNG;https://www.youtube.com/watch?v=X5b7CtABvrk;License: Standard Youtube License