I'm new on this java programming. And I need to make this program loop the Question "Do you want to Try Again?! [Yes/No]" and loop it back to "Enter any year:" question. How will I do that?
I hope you provided me with more elaborated answer or example to make this program work properly within today..
import java.util.Scanner;
public class my_LeapYear {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Enter any year: ");
int year = s.nextInt();
boolean loop = true;
while(loop == true)
{
if (((year %4==0)&& (year %100 !=0))||(year %400==0))
{
System.out.println("Year "+year+" is a Leap Year");
break;
}
else if ((year %100 == 0)&&(year %400 == 0))
{
} else {
System.out.println("Year "+year+" is not a Leap Year");
loop = false;
break;
}