Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Exercises Chapter 5
- Number 2
- Number 4
- public class Pg378_4
- {
- public static void randomX(int a, int b)
- {
- Random rand = new Random
- int x = rand.nextInt(16);
- while(a <= 16)
- {
- for(int a; a<= 16; a++)
- {
- System.out.println("x);
- }
- }
- }
- }
- Number 6
- public class Pg378_6
- {
- public static void makeGuesses()
- {
- while(x >= 48)
- {
- x = rand.nextInt(50) + 1;
- System.out.println("Guess = " + x);
- a++;
- }
- System.out.println("total guesses = " + a);
- }
- }
- Number 8
- public class Pg379_8
- {
- public static void randomWalk()
- {
- while(x > -3 || x < 3)
- {
- int a = 0
- x = rand.nextInt(1)
- if(x == 1)
- {
- a++;
- System.out.println("postion = " + a);
- }
- else
- {
- a--;
- System.out.println("postion = " + a);
- }
- }
- }
- Number 10
- Number 12
- public class Pg380_12
- {
- public static void printAverage()
- {
- while( x > 0)
- {
- Scanner console = new Scanner(System.in);
- System.out.println("Guess = ");
- for(int i = 1; i <= x; i ++)
- int xi = console.nextInt;
- System.out.print(x);
- }
- average=(x1+x2+x3)/2;
- System.out.println(average);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement