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

Python 3.7.4: The current calendar, called the Gregorian calendar, was introduced in 1582. Every year divisible...
Python 3.7.4: The current calendar, called the Gregorian calendar, was introduced in 1582. Every year divisible by four was created to be a leap year, with the exception of the years ending in 00 (that is, those divisible by 100) and not divisible by 400. For ­instance, the years 1600 and 2000 are leap years, but 1700, 1800, and 1900 are not. Write a program that requests a year as input and states whether it is a leap year. We...
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...
I need this before the end of the day and in java please :) 10.12 Lab...
I need this before the end of the day and in java please :) 10.12 Lab 9 In BlueJ, create a project called Lab9 A car dealership pays their salesmen a base salary every month. However, based on how many cars they sold (qtySold) they get a percentage of their salary as a bonus. To determine the percent bonus, the company uses the following chart. qtySold %Bonus 5 or less 0% More than 5 but 10 or less 5% More...
Write a java program MyCalendar that outputs a monthly calendar for a given month and year....
Write a java program MyCalendar that outputs a monthly calendar for a given month and year. the output should be looks like this one at the bottom:( I don't know why it doesn't show right but the first day of the month is not Sunday it starts from Wednesday) F. Last’s My Calendar Enter month year? 10 2019 10/2019 Sun Mon Tue Wed Thu Fri Sat --------------------------------- 1 2 3 4 5 6 7 8 9 10  11 12 13 14...
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  
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