Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

I need this Java program rewritten in another manner but to have the same outcome: import java.

I need this Java program rewritten in another manner but to have the same outcome:






import java.io.*;

class Day
{
   String day;
  
   Day (String str)
   {
      day=str;
   }
  
   void setDay()
  
      throws IOException
      {
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         //System.out.println(“Set through setDay Method”);
         System.out.println(“Enter the Day: “);
         day=br.readLine();  
         System.out.println(” “);     
      }
  
  
   void printDay()
   {
      //System.out.println(“Output of printDay Method “);
      System.out.println(“Current day is: ” + day);
      System.out.println(” “);
   }
  
   String returnDay()
   {
      return day;
   }

// create a rule for the different spellings including uppercase

   String prevDay()
   {
      String str[] = new String[7];
      str[0]=”Sun”;
      str[1]=”Mon”;
      str[2]=”Tue”;
      str[3]=”Wed”;
      str[4]=”Thu”;
      str[5]=”Fri”;
      str[6]=”Sat”;
     
      String str1[] = new String[7];
      str1[0]=”sun”;
      str1[1]=”mon”;
     str1[2]=”mue”;
      str1[3]=”wed”;
      str1[4]=”thu”;
      str1[5]=”fri”;
      str1[6]=”sat”;
     
      String str2[] = new String[7];
      str2[0]=”sunday”;
      str2[1]=”monday”;
      str2[2]=”tuesday”;
      str2[3]=”wednesday”;
      str2[4]=”thursday”;
      str2[5]=”friday”;
      str2[6]=”saturday”;
     
      String str3[] = new String[7];
      str3[0]=”Sunday”;
      str3[1]=”Monday”;
      str3[2]=”Tuesday”;
      str3[3]=”Wednesday”;
      str3[4]=”Thursday”;
      str3[5]=”Friday”;
      str3[6]=”Saturday”;
     
      int x=0;
     
      for (int i=0; i<=6; i++)
      {
         if(day.equals(str[i]) || day.equals(str1[i]) || day.equals(str2[i]) || day.equals(str3[i]))
         {
            x=i;
            break;
         }
      }
    
      if (x==0)
      {
         return str3[6];
      }
      else
      {
         return str3[x-1];
      }
   }
  
   String nextDay()
   {

// create a rule for the different spellings including uppercase




      String str[] = new String[7];
      str[0]=”Sun”;
      str[1]=”Mon”;
      str[2]=”Tue”;
      str[3]=”Wed”;
      str[4]=”Thu”;
      str[5]=”Fri”;
      str[6]=”Sat”;
     
      String str1[] = new String[7];
      str1[0]=”sun”;
      str1[1]=”mon”;
      str1[2]=”tue”;
      str1[3]=”wed”;
      str1[4]=”thu”;
      str1[5]=”fri”;
      str1[6]=”sat”;
     
      String str2[] = new String[7];
      str2[0]=”sunday”;
      str2[1]=”monday”;
      str2[2]=”tuesday”;
      str2[3]=”wednesday”;
      str2[4]=”thursday”;
      str2[5]=”friday”;
      str2[6]=”saturday”;
     
      String str3[] = new String[7];
      str3[0]=”Sunday”;
      str3[1]=”Monday”;
      str3[2]=”Tuesday”;
      str3[3]=”Wednesday”;
      str3[4]=”Thursday”;
      str3[5]=”Friday”;
      str3[6]=”Saturday”;
     
      int x=0;
     
      for (int i=0; i<=6; i++)
      {
         if(day.equals(str[i]) || day.equals(str1[i]) || day.equals(str2[i]) || day.equals(str3[i]))
         {
           x=i;
            break;
         }
      }
     
      if (x==6)
     {
         return str3[0];
      }
      else
      {
         return str3[x+1];
      }
   }
  
   String calcDay() throws IOException
   {
      String x;
     
     
         BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
         System.out.println(“Enter the Number of days You want to add to the Current Day: “);
         x=br.readLine();       
     
     
      int y= Integer.parseInt(x);
     
      //System.out.println(y);
     
      String str[] = new String[7];
      str[0]=”Sun”;
      str[1]=”Mon”;
      str[2]=”Tue”;
      str[3]=”Wed”;
      str[4]=”Thu”;
      str[5]=”Fri”;
      str[6]=”Sat”;
     
      String str1[] = new String[7];
     str1[0]=”sun”;
      str1[1]=”mon”;
      str1[2]=”mue”;
      str1[3]=”wed”;
      str1[4]=”thu”;
      str1[5]=”fri”;
      str1[6]=”sat”;
     
      String str2[] = new String[7];
      str2[0]=”sunday”;
      str2[1]=”monday”;
      str2[2]=”tuesday”;
      str2[3]=”wednesday”;
      str2[4]=”thursday”;
      str2[5]=”friday”;
      str2[6]=”saturday”;
     
      String str3[] = new String[7];
      str3[0]=”Sunday”;
      str3[1]=”Monday”;
      str3[2]=”Tuesday”;
      str3[3]=”Wednesday”;
      str3[4]=”Thursday”;
      str3[5]=”Friday”;
      str3[6]=”Saturday”;
     
      int z=0;
     
      for (int i=0; i<=6; i++)
      {
         if(day.equals(str[i]) || day.equals(str1[i]) || day.equals(str2[i]) || day.equals(str3[i]))
         {
            z=i;
            break;
         }
      }
     
      z=z+y+1;
      //System.out.println(z);
      z=z%7;
      //System.out.println(z);
      z=z-1;
      if (z==-1)
      z=6;
     
      return str3[z];
   }
}

class progDay
{
   public static void main (String args[])
   {

      Day ob = new Day(“Fri”);
      ob.printDay();
      try
      {
      ob.setDay();
      }
      catch (IOException e){}
     
      //System.out.println(“Output of returnDay Method”);
      System.out.println(“Day You Entered Is: ” + ob.returnDay());
      System.out.println(” “);
      //System.out.println(“Output of nextDay Method “);
      System.out.println(“Next Day is: ” + ob.nextDay());
      System.out.println(” “);
      //System.out.println(“Output of prevDay Method “);
      System.out.println(“Previous Day is: ” + ob.prevDay());
      System.out.println(” “);
      try
      {
      //System.out.println(“Output of calcDay Method  “);
      System.out.println(“Calculated Day is: ” + ob.calcDay());
      }
      catch (IOException e){}
     
  }

 
"Looking for a Similar Assignment? Order now and Get 10% Discount! Use Code "Newclient"