Question: Please write it in Java public class for both questions. For question 1, here is the code for the leap year. import java.util.Scanner; public class

Please write it in Java public class for both questions. For question 1, here is the code for the leap year.

import java.util.Scanner;

public class Leapyears { public static void main(String[] args) { Scanner Key = new Scanner(System.in); int yr; System.out.print("Enter a year: "); yr =Key.nextInt(); if (yr % 4==0 && yr % 100 !=0){ System.out.print("Year "+yr+" is a leap year.");} else if (yr % 400==0){ System.out.print("Year "+yr+" is a leap year.");} else { System.out.print("Year "+yr+" is not a leap year.");}

} }

Please write it in Java public class for both questions. For question

1, here is the code for the leap year. import java.util.Scanner; public

Subnt your source code to PA5 dropbox on course webste before the due date. 1. Re-wrme the 2d question in your PA3, aka PA3 2java fie (open i and save it as PA5 1va) so that your progam should ask the user to enter a vear and then determine whether that year is a eap year. Repeat ntil the user enters 0 for the year. The following i anexampe program run (the user's input is underlined). Enter a year (O to stop):1960 1960 is aleap year Entera year (0 to stop): 1996 1996 is aleap year Entera year (0 to stop):2000 2000 is aleap year Entera year 0 to stop): 1961 1961 is not a le ap year. Entera year (0 to stop): 1995 1995 is not a le ap year Entera year (0 to stop): 1900 1900 is not a le ap year Entera year (0 to stop):0 Bye. 2. Count red yelow, and bie marbles. The user wil abbreviate the colors with a singe letter, as folows: r-red y- yelow bhe -quit Your program should contiualy ask the user for the color of a marble, unti q(for quit) is entered You should then display the mumber of marbles of each color as well as the total mmber of arbes Use appropriate messages for al output If a letter other than those isted above is entered dispay a warning message and ignore hat entry (but contime the program). Extra Credit (+1) Use the Booean a operator to aloa the user to type either upper ar lower case letters. Announce the name of the winming color (the color with the greatest mmber of marbes). Break tes arbirarly, but don't display more than one wimer

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!