I am doing a program and i ahve some problems here.
this is what i have so far.
import java.util.Scanner;
import java.util.*;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Reader;
public class Test
{
public static void main(String[] args) throws IOException
{
int total = 0;
int number = 0;
int numbera = 0;
while (total < 12)
{
for (int i = 1; i < 2; i++)
{
number = 1 + (int) (Math.random() * 6);
}
System.out.println("You want to roll again, y or n");
Reader r = new InputStreamReader(System.in);
char c = (char) r.read();
String s = new Character(c).toString();
if (s.equalsIgnoreCase("y"))
{
total += number;
}
else if (s.equalsIgnoreCase("n"))
{
total = number;
}
System.out.println("The total number of spots are " + total);
}
System.out.println("YOU LOSE!!!");
{
}
}
}
after i press "n" it should automatically be the computers turn.
this is are rules of the computer.
- Should generate a random number between 1 and 6 if it generates anything that =>8 it should stop and compare with my score.
- If it generates anything > 11 it losses (if i dont generate anything >11)
- Compares who wins at the end (player or computer).
Thanks