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
Bogdan [553]
3 years ago
5

A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac

count for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: 1) The year must be divisible by 4 2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year.
Computers and Technology
2 answers:
katrin [286]3 years ago
6 0

Answer:

i_year=int(input(""))

#check leap year

if((i_year % 4 == 0 and i_year % 100 != 0) or (i_year % 400 == 0)):

  print("{} is a leap year.".format(i_year))

else:

  print("{} is not a leap year.".format(i_year))

Explanation:

GREYUIT [131]3 years ago
4 0

Answer:

import java.util.Scanner;

public class LabProgram {

  public static void main(String[] args) {

      Scanner scnr = new Scanner(System.in);

      int inputYear;

      boolean isLeapYear;

      isLeapYear = false;

      inputYear = scnr.nextInt();

      // If a year is divisible by 400,  then it is a leap year

      if (inputYear % 400 == 0)

          isLeapYear = true;

      // If a year is divisible by 100,  then it is not a leap year

      if (inputYear % 100 == 0)

          isLeapYear = false;

      // If a year is divisible by 4,  then it is a leap year

      if (inputYear % 4 == 0)

          isLeapYear = true;

      if(isLeapYear)

          System.out.println(inputYear + " is a leap year.");

      else

          System.out.println(inputYear + " is not a leap year.");

  }

}

Explanation:

  • Take the year as an input from user and store it to inputYear variable.
  • If the year is a century year, check if the year is divisible by 400 ( the year must be evenly divisible by 400 ),  then set the boolean isLeapYear to true. If a year is divisible by 100,  then set the boolean isLeapYear to false. If a year is divisible by 4,  then set the boolean isLeapYear to true.
  • Check if isLeapYear is true, then print that it is a leap year. Otherwise, print that it is not a leap year.

Output:

1712

1712 is a leap year.

You might be interested in
During active listening, which response is NOT an example of providing feedback to the speaker to show that you understand his o
MaRussiya [10]

Answer:

The answer is D.

Explanation:

They/you are asking the speaker to clarify what they just said.

6 0
3 years ago
Write a java program called allDigitsOdd that returns whether every digit of a positive integer is odd. Return true if the numbe
Vlada [557]

Answer:

public class Digits

{

   public static boolean allDigitsOdd(int num)

   {

       boolean flag=true;

       int rem;

       while(num>0)

       {

           rem=num%10;

           num=num/10;

           if(rem%2==0)    // if a even digit found immediately breaks out of loop

           {

               flag=false;

               break;

           }

       }

       return flag;     //returns result

   }

   public static void main(String args[])

   {

       System.out.println(allDigitsOdd(1375));    //returns true as all are odd digits

   }

}

OUTPUT :

true

Explanation:

Above program has 2 static methods inside a class Digits. Logic behind above function is that a number is divided by 10 until it is less than 0. Each time its remainder by 0 is checked if even immediately breaks out of the loop.

4 0
3 years ago
3423509 join the kahoot its for fun its about the holidayss:)
zheka24 [161]

Answer:

:)

Explanation:

7 0
2 years ago
How do i beat the wolf-sheep-cabbage game?<br> (it's a extra credit thing on my hw)
dolphi86 [110]
I use random buttons try that if not send me a link ill help
3 0
3 years ago
Can someone please do a java computer science program for me? I’m desperate and I did not have enough time to learn the topic. I
vagabundo [1.1K]
Sure, how would you like me to send you the code?
5 0
2 years ago
Other questions:
  • You are tasked with setting up an employee’s computer.Instead of a new computer,she will be using a computer with an older opera
    11·2 answers
  • Which of the following is a reliable source of information: a book recommended from my professor, britannica, a blog, or wikiped
    6·1 answer
  • Write an expression that will cause the following code to print "Equal" if the value of sensorReading is "close enough" to targe
    9·1 answer
  • HELP PLEASE
    6·1 answer
  • Referat noaptea la școala cu sfârșit de groază​
    10·1 answer
  • Stay safe and search answers up if you need ​
    14·1 answer
  • What word can you type using only the left home row keys and the right reach keys?
    6·2 answers
  • Edhesive in JAVA Write a method that takes a String parameter. If the String has a double letter (i.e. contains the same letter
    13·1 answer
  • Write a function that takes in two parallel lists: a list of times (in increasing order), and a list of distance traveled by tha
    13·1 answer
  • B. WAP to check whether input number is palindrome number or not using SUB...... END SUB.​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!