Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assigned some code analysis, documentation and maintenance. The first notes were the original code, the bottom is the work I've done thus far; I'm stuck.
Assigned some code analysis, documentation and maintenance. The first notes were the original code, the bottom is the work I've done thus far; I'm stuck.
* Untitled - Notepad File Edit Format View Help import java.util.Scanner; public class IQuitCode { public static void main(String[] args) { boolean loop=true; /* Scanner console = new Scanner( System.in) while (loop) { System.out.print("Enter the year: ") int year= console.nextInt() System.out.println("The year is a leap year: "+ leapYear(year) ) System.out.print( "again?: char again = console.nextInt() // ha ha ha when is a char an int if (again == 1) { loop=false }//if } } public static boolean leapYear ( int year){ boolean leaped = false if (year%4==0){ leaped = true if(year>1582) { if (year%100==0&&year%400!=0){ leaped=false } } }//1st if return leaped */ } } X G QuitCode.java C:\Users\j\Documents\Java Advanced - GRASP CSD (Java) Eile Edit View Build Project Settings Tools Window Help - OX ed - J BD JIQL WH 1 2 3 import java.util.Scanner; 4 //What are the inputs for the program? 5 //years: integers = YYYY 6 //what are the outputs for the program? 7 //a true or false 8 //what calculations does it perform? 9 //boolean t/f if the numbers given are a multiple of 400, multiple of 4, but not of 100 10 // what does the program do overall? 11 //Calculate if a user-provided year is a Leap year or not 12 13 public class IQuitCode { /**main method that runs when the program starts*/ 14 15 public static void main(String[] args) { 16 boolean loop = true; a boolean argument that is always true so always prints enter the year */ 18 19 Scanner console = new Scanner( System.in); 20 while (loop) 21 System.out.println(" Enter the year: "); 22 // new scanner to prompt from the console. Scanner in = new Scanner(System.in); int year = in.nextInt(); System.out.println("The year" + leapYear(year) + is a leap year."); 17 class leapYear { /**Class to see if leap year is true or false*/ public static boolean leapYear (int year) { 32 if (year % 400 == ) return true; /** if multiple of 400 */ if (year % 4 == 0 && year % 100 !=0) return true; /** if multiple of 4 but not 100 */ return false; /** otherwise return false */ } 37 38 } 39 40 } 41 } G IQuitCode.javaStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started