Hi, I wonder if anyone could help.
I'm pretty new to programming. In the process of creating a random month and season generator. Seems to be successful so far. However I'd like it to print out the remaining months of the year that were not selected by the random month generator. Right now it always pints out my current IF statement, regardless of whether it's the correct decision or not.
Been really stuck on this for the past week. I've tried to store months[monthChooser.nextInt(11) as variable so I could say:
if months[monthChooser.nextInt(11).equals("Jan"));
But I can't figure out how to store it as a variable so I can print the remaining months of the year depending on what month the generator selects randomly. Not sure that would even work anyway. Can anyone help me with this? Really stuck!
Here is what I have so far:
___________________________________
package day1.examples;
import java.util.Random;
public class MonthSeason {
public static void main(String[] args) {
String[] seasons = {"Spring","Summer","Autumn","Winter"};
String[] months = {"Jan", "Feb","Mar","Apr","May","Jun","Jul","Aug","Sept"," Nov","Dec"};
Random seasonChooser = new Random();
Random monthChooser1 = new Random();
System.out.print("You've been allocated ");
System.out.print(months[monthChooser1.nextInt(11)]);
System.out.print(" which is in ");
System.out.print(seasons[seasonChooser.nextInt(3)]);
System.out.println(".");
System.out.println("The other months of the year are: ");
if(months.equals("Jan"));
System.out.println("Feb, Mar, Apr, May, June, Jul, Aug, Sept, Nov, Dec");
}
}
___________________________________