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]
2 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]2 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
When parking ur vehicle facing downhill with a curb, you should point ur front wheels?
Genrish500 [490]
Wheels should be pointing towards the curb. this is in case your vehicle rolls, if it does, the wheel will hit the curb and stop the car, it will also prevent the car from going into the road and incoming traffic. vice versa when parking uphill, point wheels away from curb, that is also to prevent the car from rolling to incoming traffic.
6 0
2 years ago
Read 2 more answers
The remove() method in the Queue interface ________. Group of answer choices retrieves, but does not remove, the head of this qu
salantis [7]
<h2>Question:</h2>

The remove() method in the Queue interface ________.

A. retrieves, but does not remove, the head of this queue, returning null if this queue is empty

B. retrieves and removes the head of this queue, or null if this queue is empty

 

C. retrieves, but does not remove, the head of this queue, throwing an exception if this queue is empty

D. retrieves and removes the head of this queue and throws an exception if this queue is empty

<h2>Answer:</h2>

D. retrieves and removes the head of this queue and throws an exception if this queue is empty

<h2>Explanation:</h2>

In Java, the Queue interface is found in the java.util package and inherits from the Collection interface. It is used to store elements which are processed in the order in which they are inserted. This means that the first element will be processed first.

The Queue interface has many methods. Some of them are;

i. add(): allows elements to be added to the queue.

ii. remove(): retrieves and removes elements from the head of the queue. The head of the queue points to the first element of the queue. If the queue is empty, the remove() method throws an exception called the <em>NoSuchElementException</em>

<em />

iii. poll(): retrieves and removes the element at the head of the queue. Unlike the remove() method, if the queue is empty, a <em>null </em>is returned.

iv. peek(): retrieves but does not remove the element at the head of the queue. Just like the poll() method, a <em>null</em> is returned if the queue is empty.

7 0
2 years ago
Advantages of a personal area network
Ratling [72]
The main advantage is the security, the pan is a personal network of one or two person so there is no risk of any leak of data, best way to share resources each other via bluetooth

4 0
3 years ago
Which is the most likely reason why scientists change a model?
frozen [14]

C.) New discoveries make the current model inaccurate. Since science is all about observation and experimentation, it is logical that whenever new findings are gathered, scientific models must be modified to adapt to the information. As new ideas and concepts are uncovered, models should be updated to make them correct.

5 0
3 years ago
Read 2 more answers
Which security scanner runs in a web browser and doesn't require that you install a product before scanning
balandron [24]

Answer:

It’s OSI. also your question cut off lol

4 0
2 years ago
Other questions:
  • Ergonomically designed workstations and equipment reduce stress-related injuries and improve the productivity and efficiency of
    13·2 answers
  • Ciscon Telecom is a mobile operator in the European Union. The company provides personalized services to its customers, and its
    8·2 answers
  • Your wireless network consists of multiple 802.11n access points that are configured as follows: SSID (hidden): CorpNet Security
    8·1 answer
  • A monopoly is a market that has few competing businesses. many sellers of the same item. many sellers of a variety of products.
    8·2 answers
  • 2. Used to drive in or remove screws that fasten electrical wires or other electrical accessories. A. Pliers C. Screwdrivers B.
    15·1 answer
  • Computer science - algorithms - flowcharts
    11·1 answer
  • Even though jdoe and jrock have the same password (i.e., hacker), their password hashes in the /etc/shadow file are different. W
    15·1 answer
  • In a program you need to store identification numbers of 5 employees and their weekly gross pay.
    11·1 answer
  • WHAT ARE THE USES OF COMPUTER SCIENCE AND INFORMATION TECHNOLOGY
    13·1 answer
  • Many phone fraud scammers are expessily cunning because they approach the target to try to sell
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!