Can I count each time the variable choice is one or each time the variable choice is two then add up the total times each count was generated?
Ross Gerard is: Drinking some coffee
Ross Gerard is: At work
Ross Gerard is: Eating a snack
Ross Gerard is: At work
Ross Gerard is: Playing with the dogs
Ross Gerard is: Primping in the mirror
Ross Gerard is: Doing Jiu-Jitsu
Ross Gerard is: Playing with the dogs
Ross Gerard is: Eating a snack
Ross Gerard is: Walking
Ross Gerard is: Eating a snack
Ross Gerard is: Playing nintendo
Ross Gerard is: Playing with the dogs
Ross Gerard is: Singing
Ross Gerard is: Walking
Ross Gerard is: Kissing his girlfriend
Ross Gerard is: At work
Ross Gerard is: Swimming
Ross Gerard is: Playing nintendo
Ross Gerard is: Studying Java
import java.util.Random;
class student
{
public void studentIsDoing()
{
for (int counter = 0; counter < 20; counter++)
{
Random r = new Random();
int choice = 1 + r.nextInt(15);
String response = "";
if ( choice == 1 )
response = "Playing with a ball";
else if ( choice == 2 )
response = "Studying Java";
else if ( choice == 3 )
response = "Kissing his girlfriend";
else if ( choice == 4 )
response = "Swimming";
else if ( choice == 5 )
response = "Doing Jiu-Jitsu";
else if ( choice == 6 )
response = "Reading a paper";
else if ( choice == 7 )
response = "Singing";
else if ( choice == 8 )
response = "Primping in the mirror";
else if ( choice == 9 )
response = "Taking a Shower";
else if ( choice == 10 )
response = "Eating a snack";
else if ( choice == 11 )
response = "Drinking some coffee";
else if ( choice == 12 )
response = "Walking";
else if ( choice == 13 )
response = "Playing with the dogs";
else if ( choice == 14 )
response = "At work";
else if ( choice == 15 )
response = "Playing nintendo";
else
response = "In the Bathroom";
System.out.println( "Ross Gerard is: " + response );
}
}
}
Aucun commentaire:
Enregistrer un commentaire