1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
ale4655 [162]
3 years ago
5

Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is h = (q + 26(m

+1)//10 + k + k//4 +j//4 +5j) % 7 where - h is the day of the week (0: Saturday, 1: Sunday, 2: Monday, 3: Tuesday, 4: Wednesday, 5: Thursday, 6: Friday). - q is the day of the month. - m is the month (3: March, 4: April, ..., 12: December). January and February are counted as months 13 and 14 of the previous year. - j is year//100. - k is the year of the century (i.e., year % 100). Write a program that prompts the user to enter a year, month, and day of the month, and then it displays the name of the day of the week.

Computers and Technology
1 answer:
iragen [17]3 years ago
5 0

Answer:

Here is the program:

import java.util.Scanner;   // to accept input from user

public class Main {  //class definition

public static void main(String[] args) {  //start of main function

 Scanner input = new Scanner(System.in);  //creates Scanner class object

 System.out.print("Enter year: ");  //prompts user to enter Year

 int year = input.nextInt();  // reads input year from user

 System.out.print("Enter month: ");  //prompts user to enter month

 int month = input.nextInt();  // reads input month from user

 System.out.print("Enter the day of the month: ");  //prompts user to enter day of month

 int dayM = input.nextInt();  // reads input day of month from user

 if (month == 1 || month == 2){  //if month is January or February

  month = (month == 1) ? 13 : 14;  //if month is January set month to 13 and 14 otherwise

  year--; }  //decrements value of year

int dayW = (dayM + (26 * (month + 1)) / 10 + (year % 100)  

   + (year % 100) / 4 + (year / 100) / 4 + 5 * (year / 100)) % 7;   //computes day of the week

      System.out.print("Day of the week is ");  //prints day of week

 switch(dayW)  {  //used to print day of the week

  case 0: System.out.println("Saturday"); break;  //if 0 then displays Saturday

  case 1: System.out.println("Sunday"); break; //1 then displays Sunday

  case 2: System.out.println("Monday"); break;  //2 then displays Monday

  case 3: System.out.println("Tuesday"); break;  //3 then displays Tuesday

  case 4: System.out.println("Wednesday"); break;  //4 then displays Wednesday

  case 5: System.out.println("Thursday"); break;  //5 then displays Thursday

  case 6: System.out.println("Friday");   }  }       } //6 then displays Friday

Explanation:

The program first prompts the user to enter the values of year, month and day of month. Then uses the following formula to compute day of the week in that particular year, month and day of week:

Suppose

year = 2020

month = 9

day of month = dayM = 6

Then dayM is calculated as

(dayM + (26 * (month + 1)) / 10 + (year % 100)  

   + (year % 100) / 4 + (year / 100) / 4 + 5 * (year / 100)) % 7

(6+ (26 * (9+ 1)) / 10 + (2020% 100)  

   + (2020% 100) / 4 + (2020/ 100) / 4 + 5 * (2020/ 100)) % 7;

This gives answer as 1.

Now if we see the switch statement the day corresponding to 1 is Sunday

So the day on year 2020, month 9 and day of the month 6 is Sunday.

The screenshot of program along with its output is attached.

You might be interested in
Why does Zoologist have no work experience in a related occupation?
FromTheMoon [43]

A zoologist has no work in animal health like a veterinarian does even though they study animals.

5 0
3 years ago
Which of the following statements is true of ASCII code?
Tju [1.3M]

Answer:

Option A: It includes letters and numbers.

Explanation:

ASCII is the abbreviation of American Standard Code for Information Interchange. This is a character encoding standard to represent letters (upper case and lower case), numbers and special characters (e.g. & and %).  This is an encoding standard which is recognized by all computers that enable the exchange of information between different computers become possible.

For example, an uppercase A is represented as number 65 in ASCII code.

5 0
3 years ago
Code Problem 3 in Python 2.
11111nata11111 [884]

I've included my code in a picture below. I hope this helps.

7 0
3 years ago
But this time use 16 kib pages instead of 4 kib pages. what would be some of the advantages of having a larger page size? what a
uranmaximum [27]

Here are the advantages and disadvantages of larger paper size: 

Advantages: 

Reduces minor page faults. 

Disadvantages: 

There will be a decrease in the number of frames. 

There will be an increase number of page faults. 

<span>Waste of more space with the internal fragmentation.</span>

6 0
3 years ago
Which of the Arts, A/V Technology, and Communication career cluster pathways are involved with producing a product for an audien
PIT_PIT [208]

I believe the pathways are Audio/Visual Technology and Film, Journalism and Broadcasting and Printing Technology .


5 0
3 years ago
Read 2 more answers
Other questions:
  • The spreadsheet below shows the names years in office, and number of terms for five US presidents
    7·2 answers
  • Most licensing agencies offer an orientation meeting for applicants who want to obtain licensing for a child care facility or a
    12·2 answers
  • Pascal's Triangle is a triangular array in which every number represents the
    15·1 answer
  • Josh wants to convey his best wishes to johnathin for a meeting schedualed later diring the day. Which business documented would
    7·1 answer
  • A law office has been leasing dark fiber from a local telecommunications company to connect a remote office to company headquart
    14·1 answer
  • When the CSS property of position is set to ____ it moves the element relative to its original position and allows other element
    10·1 answer
  • John is runnig his Database application on a single server with 24 Gigabytes of memory and 4 processors. The system is running s
    6·1 answer
  • QUESTION 4 of 10: What term refers to the basic characteristics of a population segment, such as gender, age, and income?
    12·2 answers
  • What is the full form of the OS?​
    15·2 answers
  • A social service agency hires accenture to improve training and experiences for caseworkers. What is one way accenture can use v
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!