I have run this code and looked online for solutions. How can I fix this error? I saved PastPresentFuture.java and it still won't run.
YourName.java:7: error: class PastPresentFuture is public, should be declared in a file named PastPresentFuture.java
public class PastPresentFuture
^
1 error
Code:
//Name
//Date
//Chapter and problem #
//Application prompts user to enter month, day, year
import java.util.*;
import java.time.LocalDate;
public class PastPresentFuture
{
public static void main (String[] args)
{
LocalDate today = LocalDate.now(); //Creates the local class of today
int mo, da, yr;
int todayMo, todayDa, todayYr;
Scanner input = new Scanner(System.in);
todayMo = today.getMonthValue();
todayDa = today.getDayOfMonth();
todayYr = today.getYear();
//Input month, day and year enter text for month, day and year
System.out.print("May");
mo = input.nextInt();
System.out.print("18");
da = input.nextInt();
System.out.print("2018");
yr = input.nextInt();
//Reference if and else statement example on p. 274
//Display text statements shown as (1, 2, 3, 4) on p. 295 for this problem
if(yr != todayYr)
System.out.println(yr + todayYr);
else
if(mo < todayMo)
System.out.println(mo + todayMo);
else
if(mo > todayMo)
System.out.println(mo +todayMo);
else
System.out.println(mo +todayDa);
}
}