Absolute C++
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
bartleby

Videos

Textbook Question
100%
Book Icon
Chapter 3, Problem 12PP

Write a program that inputs a date (e.g., July 4, 2008) and outputs the day of the week that corresponds to that date. The following algorithm is from http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week. The implementation

will require several functions:

bool isLeapYear (int year) ;

This function should return true if year is a leap year and false if it is not. Here is pseudocode to determine a leap year:

leap_year = ((year divisible by 400) or (year divisible by 4 and year not divisible by 100))

int getCenturyValue (int year) ;

This function should take the first two digits of the year (i.e., the century), divide by 4, and save the remainder. Subtract the remainder from 3 and return this value multiplied by 2. For example, the year 2008 becomes ( 20 / 4 ) = 5 remainder 0.3 0 = 3. Return 3 * 2 = 6.

int getYearValue (int year) ;

This function computes a value based on the years since the beginning of the century. First, extract the last two digits of the year. For example, 08 is extracted for 2008. Next, factor in leap years. Divide the value from the previous step by 4 and discard the remainder. Add the two results together and return this value. For example, from 2008 we extract 08. Then ( 8 / 4 ) = 2 remainder 0. Return 2 + 8 = 10.

int getMonthValue (int month, int year) ;

This function should return a value based on the following table and will require invoking the isLeapYear function:

Chapter 3, Problem 12PP, Write a program that inputs a date (e.g., July 4, 2008) and outputs the day of the week that

Finally, to compute the day of the week, compute the sum of the date’s day plus the values returned by getMonthVaIue, getYearVaIue, and getCenturyVaIue. Divide the sum by 7 and compute the remainder. A remainder of 0 corresponds to Sunday, 1 corresponds to Monday, etc.—up to 6—which corresponds to Saturday. For example, the date July 4, 2008 should be computed as ( day of month )  +  ( getMonthVaIue )  + ( getYearVaIue )  +  ( getCenturyVa1ue )  = 4 + 6 + 10 + 6 = 26 .26/7 = 3 remainder 5. The fifth day of the week corresponds to Friday.

Your program should allow the user to enter any date and output the corresponding day of the week in English.

Blurred answer
Students have asked these similar questions
Write a DECIMATOR function that takes a unit of character and minimizes it (i.e. removes the last 1/10 of characters). Always zoom in: if a bullet unit has 21 characters, 1/10 of the characters will be 2.1 characters, so DECIMATOR removes 3 characters. DECIMATOR is not kind! Examples decimator ("1234567890") 12 "123456789" # 10 characters, taken out 1. decimator ("1234567890AB") # 12 characters, 2 are released. "1234567890" decimator ("123") "12" # 3 characters, taken out 1. decimator ("123456789012345678901") # 21 characters, issued 3. Solve in Ruby "123456789012345678"
Please answer it in Python Write a double_consonant function , It takes a word as a parameter and has two return values : A Boolean value equals True If the word contains a double consonant ( The same consonant twice in a row ), under these circumstances , The second value returned is the double consonant ; If there are no double consonants , Function should return False and None. relevant information : To simplify the exercise , We don't use words that contain multiple double consonants ( for example ,“successor”) Test your functionality on . Example : double_consonne('arrivee') vaut True, 'r'.double_consonne('bonbon') vaut False, Nonedouble_consonne('reussite') vaut True, 's'
Code in Python Write a function, print_integers_less_than(n), which takes an integer parameter n and prints each integer k which is at least 0 and is less than n, in ascending order.  Hint: use a simple for loop. For example: Test Result print_integers_less_than(2) 0 1 print_integers_less_than(5) 0 1 2 3 4 print_integers_less_than(-3)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY