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
Goryan [66]
3 years ago
11

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.

Ex: If the input is 1712, the output is:

1712 is a leap year.
Ex: If the input is 1913, the output is:

1913 is not a leap year.
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();

/* Type your code here. */
}
}
Computers and Technology
2 answers:
Bas_tet [7]3 years ago
8 0

Answer:

def is_leap_year(year):

  if(year % 400 == 0):

      return True

  elif year % 100 == 0:

      return False

  elif year%4 == 0:

      return True

  else:

      return False  

if __name__ == '__main__':

  n = int(input())

  if(is_leap_year(n)):

      print(n,"is a leap year.")

  else:

      print(n, "- not a leap year")

Explanation:

denpristay [2]3 years ago
5 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:

If a year is 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
What is the output?
Vinvika [58]

Answer:

20

Explanation:

4 0
3 years ago
(Display four patterns using loops) Ask the user to enter an integer to
fomenos

Answer:

Hi There was small mistake. It is working fine for me. When you run from command line - use LoopPattern, not looppatern

import java.util.Scanner;

public class Looppattern {

  public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);

      System.out.println("Enter how man levels you need: ");

      int levels = sc.nextInt();

      System.out.println("\n---------------Pattern A-----------------\n");

      for (int p = 1; p <= levels; p++) {

          for (int k = 1; k <= p; k++) { // increasing each level printing

              System.out.print(k);

          }

          System.out.println();

      }

      System.out.println("\n---------------Pattern B-----------------\n");

      int r = levels;

      for (int p = 1; p <= levels; p++) {

          for (int k = 1; k <= r; k++) {

              System.out.print(k);

          }

          r--; // decreasing levels

          System.out.println();

      }

      System.out.println("\n---------------Pattern C-----------------\n");

      for (int p = 1; p <= levels; p++) { // here incresing

          for (int k = p; k > 0; k--) { // and here decreasing pattern to

                                          // achieve our required pattern

              System.out.print(k);

          }

          System.out.println();

      }

      System.out.println("\n---------------Pattern D-----------------\n");

      r = levels;

      for (int p = 1; p <= levels; p++) {

          for (int k = 1; k <= r; k++) {

              System.out.print(k);

          }

          r--; // decreasing levels

          System.out.println();

      }

  }

}

Explanation:

4 0
3 years ago
A____consists of many users and their information.​
grin007 [14]

<u>Active Directory</u> consist of many users and their information.

7 0
1 year ago
Read 2 more answers
Create a new Die object. (Refer to Die.html for documentation.)Create a loop that will iterate at least 100 times. In the loop b
hjlf

Answer:

Java code is given below

Explanation:

import java.util.Random;

class Die{

private int sides;

public Die(){

sides = 6;

}

public Die(int s){

sides = s;

}

public int Roll(){

Random r = new Random();

return r.nextInt(6)+1;

}

}

class DieRoll{

public static void main(String[] args) {

Die die = new Die();

int arr[] = new int[6];

for(int i=0; i<6; i++)

arr[i] = 0;

for(int i=0; i<100; i++){

int r = die.Roll();

arr[r-1]++;

}

for(int i=0; i<6; i++)

System.out.println((i+1)+" was rolled "+arr[i]+" times.");

}

}

8 0
3 years ago
A blue line, called a ____ line, that appears when you are dragging a GUI object on a Windows Form object indicates that the obj
ser-zykov [4K]

Answer:

snap

Explanation:

The line which appears when we are dragging an object of GUI on a object of  windows Form indicates that the object that is being dragged is aligned horizontally with the object which is connected by the blue line is called a snap line.

Hence we conclude that the answer to this question is snap line.

3 0
3 years ago
Other questions:
  • What aspect of the internet makes it fault-tolerant?
    6·1 answer
  • Assume arr2 is declared as a two-dimensional array of integers. Which of the following segments of code successfully calculates
    6·1 answer
  • What does software alone enable a computer to do? connect to the Internet control processing speeds interact with the user manag
    11·2 answers
  • How do I change the selected cell to 20 pt
    8·2 answers
  • On five lane roadways, the center lane is designated for __________ and is used by vehicles traveling in both directions.A. Thro
    15·1 answer
  • I prefer a job where I am praise for good performance or I am accountable for results
    13·1 answer
  • A network technician is attempting to add an older workstation to a Cisco switched LAN. The technician has manually configured t
    11·1 answer
  • I still haven't figured out how to award someone branliest will someone help me? If you explain to me how to do it i will do awa
    14·1 answer
  • For a direct-mapped cache design with a 64-bit address, the following bits of the address are used to access the cache
    7·1 answer
  • In order to get the maximum functionality out of a device that is plugged in, a user should download the specific ___ for that d
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!