title: error: class, interface, or enum expected
body: <p>I have the following code that I am trying to get working for a project in a class that I am in. I will also include the requirements</p>
  
  <p>Design and implement the class Day that implements the day of the week in a program.  The class Day should store the day, such as Sun for Sunday.  The program should be able to perform the following operations on an object of type Day:</p>
  
  <p>A. Set the day.</p>
  
  <p>B. Print the day.</p>
  
  <p>C. Return the day.</p>
  
  <p>D. Return the next day.</p>
  
  <p>E. Return the previous day.</p>
  
  <p>F. Calculate and return the day by adding certain days to the current day.  For example, if the current day is Monday and we add four days, the day to be returned is Friday.  Similarly, if today is Tuesday and we add 13 days, the day to be returned is Monday.</p>
  
  <p>G. Add the appropriate constructors.</p>
  
  <p>H. Write the definitions of the methods to implement the operations for the class Day, as defined in A through G.</p>
  
  <p>I. Write a program to test various operations on the class Day.</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>`import java.util.*;
  
  
  class Day {
  private int dayValue;
  private static final int INVALID = -1;
  public Day() { this.dayValue = INVALID; }
  public Day(String day) { setDay(day); }
  public Day(int day) { this.dayValue = (day&lt;0 || day&gt;6) ? INVALID : day; }
  public void setDay(String day) {
      if(day.equals("sunday") || day.equals("Sun")) {
          this.dayValue = 0;
      } else if(day.equal("monday") || day.equals("Mon")) {
          this.dayValue = 1;
      } else if(day.equals("tuesday") || day.equals("Tues")) {
          this.dayValue = 2;
      } else if(day.equal("wednesday") || day.equals("Wed")) {
          this.dayValue = 3;
      } else if(day.equals("thursday") || day.equals("Thurs")) {
          this.dayValue = 4;
      } else if(day.equal("friday") || day.equals("Fri")) {
          this.dayValue = 5;
      } else if(day.equal("saturday") || day.equals("Sat")) {
          this.dayValue = 6;
      } else {
          this.dayValue = INVALID;
      }
  }
  
  public String getDay() {
      if (dayValue==0) { return "Sunday"; }
      if (dayValue==1) { return "Monday"; }
      if (dayValue==2) { return "Tuesday"; }
      if (dayValue==3) { return "Wednesday"; }
      if (dayValue==4) { return "Thursday"; }
      if (dayValue==5) { return "Friday"; }
      if (dayValue==6) { return "Saturday"; }
  
      return "\"I don't know what day it is!\"";
  
  }
  public void printDay() {
      System.out.println("When printing, your day is " + getDay()); //displays the day at the time of printing.
  }
  // Next Day
  public String getNextDay()
    {
       // the compareTo() method allows us to set saturday as Sat, Sunday to Sun, etc
       if((day.compareTo("sunday") == 0) || (day.compareTo("Sun") == 0))
          return ("Monday");
       else if((day.compareTo("monday") == 0) || (day.compareTo("Mon") == 0))
          return ("Tuesday");
       else if((day.compareTo("tuesday") == 0) || (day.compareTo("Tue") == 0))
          return ("Wednesday");
       else if((day.compareTo("wednesday") == 0) || (day.compareTo("Wed") == 0))
          return ("Thursday");
       else if((day.compareTo("thursday") == 0) || (day.compareTo("Thu") == 0))
          return ("Friday");
       else if((day.compareTo("friday") == 0) || (day.compareTo("Fri") == 0))
          return ("Saturday");
       else if((day.compareTo("saturday") == 0) || (day.compareTo("Sat") == 0))
          return ("Sunday");
       else
          return ("\"I don't know what day it is!\"");
    }
    // Previous day
    public String getPreDay()
    {
       if((day.compareTo("sunday") == 0) || (day.compareTo("Sun") == 0))
          return ("Saturday");
       else if((day.compareTo("saturday") == 0) || (day.compareTo("Sat") == 0))
          return ("Friday");
       else if((day.compareTo("friday") == 0) || (day.compareTo("Fri") == 0))
          return ("Thursday");
       else if((day.compareTo("thursday") == 0) || (day.compareTo("Thu") == 0))
          return ("Wednesday");
       else if((day.compareTo("wednesday") == 0) || (day.compareTo("Wed") == 0))
          return ("Tuesday");
       else if((day.compareTo("tuesday") == 0) || (day.compareTo("Tue") == 0))
          return ("Monday");
       else if((day.compareTo("monday") == 0) || (day.compareTo("Mon") == 0))
          return ("Sunday");
          return ("\"I don't know what day it is!\"");
    }
  public Day calcDay(int offset) { /* your code here */ }
  // extra good for printin
  public String toString() { return getDay(); }
  }
  
  
    // main execution point
   public static void main (String args[]) {
    {
     // One of its weakness is the case sensitive: sun, Sunday, sunday, SuNdAy...
     // need more codes to avoid this case sensitiveness...
  
     // instantiate testday object of type MyDay class
       // with "Sun" as initial value....
       Day testday = new Day("Sun");
       // prompt user to set his/her day
       System.out.print("Enter day to set your day: ");
       // read and store user's day
       String storeday = readinput.nextLine().toLowerCase(); //Changes input into all lowercase to deal with variations
       // invoke setDay() method to set a day defined by user
       testday.setDay(storeday);
       // invoke getDay() method to get a day
       System.out.println("Your day is " + testday.getDay());
       // test printing by invoking printDay() method
       testday.printDay();
       // invoke getPreDay() method to get the previous day
       System.out.println("Your previous day is " + testday.getPreDay());
       // invoke getNextDay() method to get the next day
       System.out.println("Your next day is " + testday.getNextDay());
  
       System.out.println("How many Days would you like to add? " + testday.calcNextDay());
    }
  
  
  }`
  </code></pre>
  
  <p>I am receiving the following error: </p>
  
  <pre><code>Day.java:92: error: class, interface, or enum expected
       public static void main () {
  
                     ^
  Day.java:101: error: class, interface, or enum expected
           System.out.print("Enter day to set your day: ");
  
           ^
  Day.java:103: error: class, interface, or enum expected
           String storeday = readinput.nextLine().toLowerCase(); //Changes input into all lowercase to deal with variations
           ^
  Day.java:105: error: class, interface, or enum expected
           testday.setDay(storeday);
           ^
  Day.java:107: error: class, interface, or enum expected
           System.out.println("Your day is " + testday.getDay());
           ^
  Day.java:109: error: class, interface, or enum expected
           testday.printDay();
           ^
  Day.java:111: error: class, interface, or enum expected
           System.out.println("Your previous day is " + testday.getPreDay());
           ^
  Day.java:113: error: class, interface, or enum expected
           System.out.println("Your next day is " + testday.getNextDay());
           ^
  Day.java:115: error: class, interface, or enum expected
           System.out.println("How many Days would you like to add? " + testday.calcNextDay());
           ^
  Day.java:116: error: class, interface, or enum expected
        }
        ^
  10 errors
  </code></pre>
  
  <p>Originally my code looked like this </p>
  
  <p><code>public class Day
      {
        static Scanner readinput = new Scanner(System.in);<br>
        String day;
        public Day(String day)
        {
           day = "Sunday";
        }
        // set the day
        public void setDay(String theDay)
        {
           day = theDay;
        }
        public String getDay()
        {
           return day;
        }
        public void printDay()
        {
           System.out.println("When printing, your day is " + day);
        }</code>  </p>