Java help menu

Shout-Out

User Tag List

Thread: Java help

Results 1 to 6 of 6
  1. #1
    Strath's Avatar Elite User
    Reputation
    586
    Join Date
    Apr 2013
    Posts
    523
    Thanks G/R
    75/136
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Java help

    Code:
    You will then modify it to ask the user for a color. You will ask them again and again until they guess “red” OR they have run out of guesses, i.e. they have guessed the wrong color 4 times.
    You will then give them some feedback.
    Note: you will need to use at most one loop and one condition to get full credit.
    Code:
    Example 1:
    What is your name? Jordan
    What color do you guess? White
    let’s try again: What color do you guess? red
    “Congratulations! You guessed the correct color in 2 tries.”
    
    
    Example 2:
    What is your name? Jordan
    What color do you guess? White
    let’s try again: What color do you guess? Blue
    let’s try again: What color do you guess? Green
    let’s try again: What color do you guess? Yellow
    let’s try again: What color do you guess? Violet
    “Jordan, you ran out of guesses, sorry!”

    Java help
  2. #2
    Augury13's Avatar Legendary
    Reputation
    884
    Join Date
    Oct 2012
    Posts
    1,736
    Thanks G/R
    424/74
    Trade Feedback
    7 (100%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    White isn't a color, its the absence of color.

    also i can make this in notepad - command prompt if u want

  3. #3
    Strath's Avatar Elite User
    Reputation
    586
    Join Date
    Apr 2013
    Posts
    523
    Thanks G/R
    75/136
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    getttttttttttoutttttttttttttttttttttttttt xD

  4. #4
    Strath's Avatar Elite User
    Reputation
    586
    Join Date
    Apr 2013
    Posts
    523
    Thanks G/R
    75/136
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by tmanowen View Post
    White isn't a color, its the absence of color.

    also i can make this in notepad - command prompt if u want
    I can do it in a batch, but I need it in java.

  5. #5
    Augury13's Avatar Legendary
    Reputation
    884
    Join Date
    Oct 2012
    Posts
    1,736
    Thanks G/R
    424/74
    Trade Feedback
    7 (100%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Strath2121 View Post
    I can do it in a batch, but I need it in java.
    wewtz @ batch files!

  6. #6
    ClearFlare's Avatar Contributor
    Reputation
    105
    Join Date
    Mar 2007
    Posts
    268
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Know hes banned, but hopefully this helps someone.

    Code:
    import java.util.*;
    import java.io.*;
    
    
    
    
    public class colorQuestion
    {
                public static void main(String[] args)
                {
            Scanner kb = new Scanner(System.in);
            System.out.println("What is your name? ");
            String name = kb.next();
            System.out.println("");
            String ans = "";
            for(int i = 0; i < 4; i++)
            {
                System.out.println("What color do you guess? ");
                ans = kb.next();
                System.out.println("");
                if(ans.equalsIgnoreCase("red"))
                {
                    System.out.println("Congratulations! You guessed the correct color in " + (i+1) + " tries.");
                    System.exit(0);
                }
                else
                {
                    System.out.print("let's try again: ");
                }
            }
            System.out.println(name + ", you ran out of guesses, sorry!");
        }
    }

Similar Threads

  1. Fishing Bot in Java Help
    By Neverdie00 in forum WoW Memory Editing
    Replies: 8
    Last Post: 03-22-2010, 08:07 PM
  2. [Help] Java program
    By Pietje in forum Community Chat
    Replies: 0
    Last Post: 11-19-2008, 05:53 PM
  3. Looking for some help with java.
    By shocking4life in forum Programming
    Replies: 1
    Last Post: 07-20-2008, 05:46 AM
All times are GMT -5. The time now is 02:54 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search