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

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); } } } }

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!