Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to write and save this coding program as a java file like Project.java impor

ID: 3852401 • Letter: H

Question

How to write and save this coding program as a java file like Project.java

import javax.swing.*;

public class LeapYear {
  
JFrame f;
int dialog(){
f=new JFrame();   
int yr=Integer.parseInt(JOptionPane.showInputDialog(f,"Enter a year "));
return yr;
}
void leapYearFind(int y){
   if((y % 400 == 0) || ((y % 4 == 0) && (y % 100 != 0)))
System.out.println("Year " + y + " is a leap year");
else
System.out.println("Year " + y + " is not a leap year");
}

public static void main(String[] args) {
LeapYear leapYear = new LeapYear();
  
while(true){
int year =leapYear.dialog();
  
if(year == -99){
   System.out.println("Program is exited");
   System.exit(0);
}else{
   leapYear.leapYearFind(year);
  
}
}
}
}

Explanation / Answer

As this program requires Java's Swing and Java's Applet classes this a GUI program.GUI stands for Graphical User Interface which is used to represent interactive Java applications and programs from which the user can easily interact.This program can not be run/viewed by saving it as a normal java program.

For these purposes there is a IDE for Java i.e. NetBeans. IDE stands for Interactive Development Environment where the user can write and design programs or application which follows GUI.

Writing & Saving the program -

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote