Compute the day of the week for any date entered by the user

Assignment Help Computer Engineering
Reference no: EM132210513

Question :

Write a program named DayOfWeek that computes the day of the week for any date entered by the user. The user will be prompted to enter a month, day, century, and year.

The program will then display the day of the week for that date as a number between 0 and 6, where 0 represents Saturday and 6 represents Friday.

The program will also print the alphabetic day of the week (Friday, Saturday, Sunday, etc.) The following example shows what the user will see on the screen:

This program calculates the day of the week for any date:

INPUT DATA

Enter month (1-12): 9

Enter day (1-31): 25

Enter century: 19

Enter year of the century: 98

OUTPUT DATA

Date is 9/25/1998

The day of the week is 6 - Friday

Hint: Use Zeller's congruence to compute the day of the week. Use all integers for the data types. Zeller's congruence relies on the following quantities:

j is the century (19 in our example, not the 20th century)

k is the year within the century (98)

m is the month (9)

q is the day of the month (25)

The day of the week is determined by the following formula:

h = (q + 26(m + 1)/10 + k + k/4 + j/4 + 5j)mod 7

The results of all divisions are truncated by the modulus operator. The value of h will lie between 0 (Saturday) and 6 (Friday). Note: Zeller's congruence assumes that January and February are treated as months 13 and 14 of the previous year; this affects the values of k and m, and possibly the value of j.

For full credit, just read in the four values (month, day, century, and year), plug them into the formula, and print the full date, h, the day of the week.

This formula assumes that January and February are months 13 and 14 of the previous year. If you want the day of week for 1 1 2006, you must type in 13 1 2005. (For 2 1 2006, type 14 1 2005 and so on)

Run the following 9 sets of data for output:

5 17 2008 (Should be 0-Sat)

10 5 2008 (Should be 1-Sun)

9 15 2008 (Should be 2-Mon)

8 5 2008 (Should be 3-Tue)

9 13 2006 (Should be 4-Wed)

1 1 2009 (Should be 5-Thu) must be typed in as 13 1 2008

2 6 2009 (Should be 6-Fri) must be typed in as 14 6 2008

1 10 2000 (Should be 2-Mon) must be typed in as 13 10 1999

Your birth date (Check the Internet or call your mom to verify this day of week!)

Reference no: EM132210513

Questions Cloud

Case study - local area network design : Detail explanation of the planning and designing of network. It is recommended that bullet points are included whenever necessary
What is the expected value and standard deviation : What are the investment proportion in the minimum variance portfolio of the selected five risky funds, and what is the expected value and standard deviation
Write a program for playing the game of nim : Write a program for playing the game of NIM. Our version of the game starts with up to 20 pegs and up to 10 discs in each peg.
Write a program to perform rounding on a floating point : Write a program to perform rounding on a floating point number input by the user, based on the fractional part of the number.
Compute the day of the week for any date entered by the user : Write a program named DayOfWeek that computes the day of the week for any date entered by the user.
Write function that creates string of path to a directory : Write a function that creates a string of the path to a directory. Use makeEmptyPicture to create a blank picture in the correct size.
Write a program to populate an array of size ten : Write a program to populate an array of size ten with ten numbers obtained through user input. Cycle through the array and generate two sums.
Design and implementation of the student registration : The administrators of Tiny College are so pleased with your design and implementation of their student registration and tracking system that they want.
Write a program that can print from lpt command : Write a program that can print from LPT command, first ask the customer to type the IP address of the printer, and then ask him to drag the file to print.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write another version of your recursive fibonacci function

Write another version of recursive Fibonacci function based on idea. In th recursive solution for calculating Nth Fibonacci number, declare an array of size N.

  Prepare the program also consider a class engineer

Consider a class "engineer" that has three attributes: name, rank, salary. Prepare the program.

  Examine difference between hierarchical and linear structure

Examine the differences between a linear and augmented linear structure. Examine the differences between hierarchical and linear structures. Explain why a coherent structure is necessary.

  Write down an equation and draw a circuit

offer below is a truth table for a combinational logic circuit with three inputs and one output. Write an equation and draw a circuit which implements the function represented by this table.

  Take movie of a location and a movie shot in front of screen

Take a movie of a location and a movie shot in front of a green screen and use chromakey to blend the two movies together.

  Write a java code to create a hash table class to use

Write a java code to Create a "Hash Table" Class to use in the Student/Faculty program as follows: The class will consist of an array of linked lists.

  Design a class bicycle that inherits from vehicle

Design a class Bicycle that inherits from Vehicle with parameters of your choice (adequate constructors).

  Describe appropriate selectional restrictions on the verbs

Cluster these senses using the definitions of homonymy and polysemy given in chapter 19 (Speech and Language Processing -Jurafsky Martin).

  Cloud to provide crm installations

What "Cloud" can provide to the CRM installations in order to ease the adoption of such systems?

  Draw the flowchart for the program

Write a program that allows the user to enter an integer n, and then generates n ransom n random number between 1 and 100.

  Design a pseudocode algorithm

design a pseudocode algorithm you would write for a simple task like making a turkey sandwich, as well as three simple control structures that could be used to create this algorithm. What do you think is the most difficult part of creating the alg..

  Determine the number of bits in a char

Write a function that performs a numerical experiment to determine the number of bits in a char, short, int, long, and long long variable type.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd