Answered step by step
Verified Expert Solution
Link Copied!

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.

image text in transcribed

image text in transcribed

* 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.java

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Relational Database And SQL

Authors: Lucy Scott

3rd Edition

1087899699, 978-1087899695

More Books

Students also viewed these Databases questions

Question

Find f'(x) for this equation f f(x) = (x2 + 3x + 4)4, find f' (x).

Answered: 1 week ago