Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Christopher Clemente
- //Comp 171-002
- //Homework #3
- import java.util.Scanner;
- public class clas {
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- int days = 0;
- System.out.println("Please enter a month and year to find out how many days are in that month.");
- System.out.print("Please enter a month (1-12) : ");
- int month = keyboard.nextInt();
- System.out.print("Please enter a year : ");
- int year = keyboard.nextInt();
- if(month == 2){
- if ((year % 4) == 0){
- days = 29;
- }
- else{
- days = 28;
- }
- }
- else if(month % 2 == 0){
- days = 30;
- }
- else{
- days = 31;
- }
- System.out.println("There are " + days + " days in month " + month);
- }
- }
- /*
- Please enter a month and year to find out how many days are in that month.
- Please enter a month (1-12) : 2
- Please enter a year : 2012
- There are 29 days in month 2
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement