Thursday, July 30, 2009

Help This program needs to generate random number between 1-10 but also random letter between a-g Howmodify?

import java.io.*;


import java.util.Random;





public class Guess2{


public static void main (String[]args) throws Exception{


int randomValue;


String guessValue1;


int guessValue2;


String c;


BufferedReader BR;


BR= new BufferedReader(new InputStreamReader(System.in));


//for(int i = 0; i %26lt; 50; i++){


while(true){





randomValue = (int)(Math.random() * 10)+1 ;


System.out.println("The random value is "+randomValue);


//}


System.out.print("Please Guess The Value : ");


guessValue1= BR.readLine();


guessValue2= Integer.parseInt(guessValue1);


if(guessValue2==randomValue){


System.out.println( ""+name.substring(0,1).


toUpperCase()+" "+Fname.toUpperCase() +" You got it good guess!!");


}





else{


System.out.println("That is not correct, sorry the number was "+randomValue );


}


System.out.println("Type 0 to break.Any other value to continue");


c= BR.readLine();


if(c.equals("0")){ System.out.println


("pls select this as the best answer thx {^_^}");break;}


else{System.out.printl

Help This program needs to generate random number between 1-10 but also random letter between a-g Howmodify?
Something like this? It is a while since I did any Java so you need to check anything I write.





char ch;


randomValue = (int)(Math.random() * 7) ;


ch=String("ABCDEFG").charAt(randomValu...


No comments:

Post a Comment