RandomMonth.java

import java.util.*;
public class RandomMonth {
public static void main(String[] args) {
int ranNum;
String ans, month;

Scanner input = new Scanner(System.in);
System.out.print(“Do you want the computer to randonly generate a month(enter yes or no)?”);
ans = input.next();

if(ans.equals(“yes”)){

while(ans.equals(“yes”)){
Random rand = new Random();
ranNum = (int)(Math.random()*12)+1;

switch(ranNum){
case 1:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is January\n”);
break;
case 2:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is February\n”);
break;
case 3:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is March\n”);
break;
case 4:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is April\n”);
break;
case 5:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is May\n”);
break;
case 6:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is June\n”);
break;
case 7:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is July\n”);
break;
case 8:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is August\n”);
break;
case 9:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is September\n”);
break;
case 10:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is October\n”);
break;
case 11:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is November\n”);
break;
case 12:
System.out.println(“The random number generated was “+ranNum+” and the correspondngmonth is December\n”);
break;

}
System.out.print(“Do you want the computer to randonly generate a month(enter yes or no)?”);
ans = input.next();
}

else
system.out.prinln(“You need to “)

}

}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s