Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
Solved

# Writing a program using the IF statement

Posted on 2004-10-26
Medium Priority
217 Views
I have to write a question usinf the IF statement.  I have to write a program to check whether or not a year inputted is or was a leap year.  A year is a leap year if it is evenly divisible by 4, except that any year divisible by 100 is a leap year only if is divisble by 400?
0
Question by:sniper4897
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 2

Author Comment

ID: 12418299
//Steven Zecca
package proj2stz;
import javax.swing.*;
public class LeapYear
{
public static void main(String[] args)
{
String s1,s2,s3;
int x,y;
y=Integer.parseInt(s1);
x=Integer.parseInt(s1);
if(y/4=x)
{
System.out.println("x is a leap year");
}
else
{
System.out.println("x is not a leap year");

}
}
}
0

Author Comment

ID: 12418304
package proj2stz;
import javax.swing.*;
public class LeapYear
{
public static void main(String[] args)
{
String s1,s2,s3;
int x,y;
y=Integer.parseInt(s1);
x=Integer.parseInt(s1);
if(y/4=x)
{
System.out.println("x is a leap year");
}
else
{
System.out.println("x is not a leap year");

}
}
}
this is what i have..but it doesn't work
0

Accepted Solution

msasikala earned 400 total points
ID: 12418741
if( (y%100==0 && y%400==0) ||(y%100!=0 && y%4==0))
{
System.out.println("y is a leap year");
}
else{
System.out.println(" y is not a leap year");
}
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Creating a Cordova application which allow user to save to/load from his Dropbox account the application database.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
###### Suggested Courses
Course of the Month8 days, 3 hours left to enroll