Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: ASSIGNMENT INVOLVING RANDOM UTIL

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ASSIGNMENT INVOLVING RANDOM UTIL

    this is the original code:

    import java.util.Scanner;

    public class GuessANumber_basic
    {
    public static final int TARGET = 37;

    public static void main(String[] args)
    {
    int guess;

    Scanner consoleIn = new Scanner(System.in);

    System.out.print("Enter a number between 1 and 100: ");
    guess = consoleIn.nextInt();


    do{
    System.out.print("Enter a number between 1 and 100: ");
    guess = consoleIn.nextInt();




    if(guess == TARGET)
    System.out.println("Congratulations! You found it.");

    else
    System.out.println("Sorry you didnt get it");

    }
    while (guess != TARGET);
    System.out.print("Congratulations! You found it. ");


    }
    }





    this is the new code for the assignment that is modified



    import java.util.Scanner;
    import java.util.Random;
    public class GuessANumber_1
    {


    public static void main(String[] args)
    {

    String name;
    int guess;
    int Target;
    int count = 0;



    { Random number = new Random();
    }

    target = num.nextInt(100);



    ScannerConselIn = new Scanner(System.in);


    do {
    System.out.print("Enter name");
    guess = consoleIn.nextInt();


    if (count == 6)
    System.out.print(" The Target was");




    if (guess > TARGET)
    System.out.print("Your guess is too high\n");

    else

    if (guess < TARGET)
    System.out.print("Your guess is too low\n");



    while(guess != TARGET);

    System.exit( 0 );



    }
    }

    This is the code that i have started



    the attachment is the questions that i am being asked to do to modify code so that it follows these steps, any help would be great
    Attached Files Attached Files
    Last edited by michael c; April 6th, 2014 at 08:38 PM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: ASSIGNMENT INVOLVING RANDOM UTIL

    Post your code correctly, ask specific questions.

Similar Threads

  1. [SOLVED] A little assignment involving arrays.
    By Melawe in forum What's Wrong With My Code?
    Replies: 39
    Last Post: May 1st, 2011, 10:43 PM
  2. [SOLVED] BlackJack.. Random Card Assignment?
    By Hallowed in forum Object Oriented Programming
    Replies: 5
    Last Post: April 5th, 2011, 07:25 AM
  3. [SOLVED] First assignment, clueless student, involving coordinates and distances
    By Kerrigan in forum Java Theory & Questions
    Replies: 7
    Last Post: March 10th, 2011, 04:52 PM
  4. random uniform distribution with probability assignment
    By blascobz in forum Object Oriented Programming
    Replies: 0
    Last Post: February 28th, 2011, 09:16 AM
  5. Replies: 8
    Last Post: February 24th, 2009, 04:04 PM