Question

In: Computer Science

In Java Please!!! 5.24 LAB: Leap year A year in the modern Gregorian Calendar consists of...

In Java Please!!!

5.24 LAB: Leap year A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account 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 - leap year Ex: If the input is: 1913 the output is: 1913 - not a leap year

Solutions

Expert Solution

//LabProgram.java
import java.util.Scanner;
public class LabProgram {
    public static boolean isLeapYear(int userYear){
        if(userYear % 4 == 0 && userYear % 100 != 0){
            return true;
        }
        else if(userYear % 400 == 0){
            return true;
        }
        return false;
    }

    public static void main(String args[]){
        Scanner scnr = new Scanner(System.in);
        int inputYear;
        boolean isLeapYear;

        isLeapYear = false;
        inputYear = scnr.nextInt();

        isLeapYear = isLeapYear(inputYear);
        if(isLeapYear){
            System.out.println(inputYear+" - a leap year");
        }
        else{
            System.out.println(inputYear+" - not a leap year");
        }
    }
}


Related Solutions

JAVA Take in a user input. if user input is "Leap Year" your program should run...
JAVA Take in a user input. if user input is "Leap Year" your program should run exercise 1 if user input is "word count" your program should run exercise 2 Both exercises should run in separate methods Exercise 1: write a java method to check whether a year(integer) entered by the user is a leap year or not. Exercise 2: Write a java method to count all words in a string.
JAVA Lab 0.2 — Calculating Averages (Averages) The file numbers.text consists of sequences of numbers, each...
JAVA Lab 0.2 — Calculating Averages (Averages) The file numbers.text consists of sequences of numbers, each sequence preceded by a header value and then followed by that many integers/ (For example the first line in the example below contains a header value of 3 followed by the three values 1, 2, and 3. Read in the sequences and print their averages. When all sequences have been read in, print out the number of sequences processed. The header and subsequent values...
In java please complete the following: A DNA sequence in FASTA format consists of a header...
In java please complete the following: A DNA sequence in FASTA format consists of a header line starting with a “>” sign, followed by a sequence identifier (GenBank Accession number, or clone name), and one or more lines of the sequence itself. Write a Java program to first prompt the user for a sequence identifier, such as “Enter a clone name: “, and then prompt for the DNA sequence. The program should print out a FASTA format sequence to the...
In Java please: 5.23 LAB: Seasons Write a program that takes a date as input and...
In Java please: 5.23 LAB: Seasons Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day. Ex: If the input is: April 11 the output is: Spring In addition, check if the string and int are valid (an actual month and day). Ex: If the input is: Blue 65 the output is: Invalid The dates for each season are: Spring:...
/////////////////JAVA PLEASE///////////////////////////////// Create a class called GVdate to keep track of a calendar date including month,...
/////////////////JAVA PLEASE///////////////////////////////// Create a class called GVdate to keep track of a calendar date including month, day and year.  You can do simple things like checking if it is your birthday, advancing to the next day, checking if a given date is valid and checking if it is a leap year. Class Fields/Instance Variables Provide appropriate names and data types for each of the private instance variables: the month, day and year (int) two final integers that represent YOUR birthday (month...
In February of the current year (assume a non-leap year), Miguel and Perla received their property tax statement for last calendar-year taxes of $3,000, which they paid to the taxing authority on March 1 of the current year.
In February of the current year (assume a non-leap year), Miguel and Perla received their property tax statement for last calendar-year taxes of $3,000, which they paid to the taxing authority on March 1 of the current year. They had purchased their home on April 1 last year. What amount of property tax on this statement may they claim as an itemized deduction this year (rounded) (Tax Year 2018)?A) $0B) $800C) $1,074D) $2,260  
In Java Please!! 6.21 LAB: Artwork label (modules) Define the Artist class in Artist.py with a...
In Java Please!! 6.21 LAB: Artwork label (modules) Define the Artist class in Artist.py with a constructor to initialize an artist's information. The constructor should by default initialize the artist's name to "None" and the years of birth and death to 0. Define the Artwork class in Artwork.py with a constructor to initialize an artwork's information. The constructor should by default initialize the title to "None", the year created to 0, and the artist to use the Artist default constructor...
In Java Please!!! 6.22 LAB: Python and sqlite basics Write a Python program that connects to...
In Java Please!!! 6.22 LAB: Python and sqlite basics Write a Python program that connects to a sqlite database. Create a table called Horses with the following fields: id (integer): a primary key and not null name (text) breed (text) height (real) birthday (text) Next, insert the following data row into the Horses table: id: 1 name: 'Babe' breed: 'Quarter Horse' height: 15.3 birthday: '2015-02-10' Output all records from the Horses table. Ex: With the above row inserted, the output...
In Java please: 3.39 Lab 6e: CharacterOps Write a program that prompts the user to enter...
In Java please: 3.39 Lab 6e: CharacterOps Write a program that prompts the user to enter their first name. Say hello to the person. Then display whether their name begins with a vowel or consonant. If it is neither, perhaps a special character or a number digit, then print neither a vowel nor a consonant. Example 1: Enter your first name: Barbara Hello, Barbara! The first letter of your name, 'B', is a consonant. Example 2: Enter your first name:...
Tabitha sells real estate on March 2 for $260,000. The buyer, Ramona, pays the real estate taxes of $5,200 for the calendar year, which is the real estate property tax year. Assume that this is not a leap year.
Tabitha sells real estate on March 2 for $260,000. The buyer, Ramona, pays the real estate taxes of $5,200 for the calendar year, which is the real estate property tax year. Assume that this is not a leap year. a. Determine the real estate taxes apportioned to and deductible by the seller, Tabitha, and the amount of taxes deductible by Ramona. b. Calculate Ramona’s basis in the property and the amount realized by Tabitha from the sale.    
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT