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: JAVA IN FINISHING SOMETHING

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JAVA IN FINISHING SOMETHING

    import java.text.DecimalFormat;
    import java.util.Locale;
    import java.util.Scanner;
    import java.text.*;
    import java.io.*;

    class CoinToes
    {
    static BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
    public static void main(String args[]) throws IOException
    {
    float numheads = 0;
    float numtails = 0;
    float numcointosses = 0;
    float correct = 0;
    float incorrect = 0;

    int toss, coinguess, randomguess;
    string answer = "y";
    string answer;

    Decimalformat pf2 = new Decimalformat ("###.0##");
    Scanner input = new Scanner(System.in);
    while(answer.equalsIgnoreCase("y"))
    {
    toss = (int)(2*Math.random())+1;

    System.out.println("Will the coin toss come up Heads or Tails ? (\"H \"for heads and \"T for tails): ");
    guess = input.nextline();
    guess = guess.tolowerCase();
    guess = guess.substring(0,1);

    if( guess.equals("h"))
    {
    System.out.println("You guessed the coin will come up \"Heads\"");
    coinguess = 1;
    }
    else if(guess.equals("t"))
    {
    System.out.println("You guessed the coin will come up \"Tails\"");
    coinguess = 2;
    }
    else
    {
    System.out.println("You enter \"t guess t\" which is NOt \"T\" or \"H\"");
    System.out.println("Randomly generating a guess for you ! ");
    if(randomguess == 1)
    {
    System.out.println("Random Guess is Heads");
    coinguess = 1;
    }
    else
    {
    System.out.println("Random Guess is Tails");
    coinguess = 2;
    }
    }
    if (toss == 1)
    {
    numheads +=1;
    System.out.println("coins comes up \"Heads\"");
    }
    else
    {
    numtails +=1;
    System.out.println("coins comes up \"Tails\"");
    }
    numcointoses +=1;


    CAN SOMEONE HELP ME FINISH THIS


  2. #2
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: JAVA IN FINISHING SOMETHING

    Quote Originally Posted by komal510 View Post
    ... CAN SOMEONE HELP ME FINISH THIS
    • Please edit your post above and surround your code with [code] [/code] tags. Please read my signature link below to see how to do this.
    • Please don't simply dump code in the forum and ask someo to "help me finish this", because that's not how it works here. We're not a work order place that finishes your homework. Instead ask a well constructed question the describes fully just what you don't understand, just what you need help with.
    • Most of these suggestions have already been given to you in replies to your previous questions. Please don't ignore these suggestions unless your goal is to have us ignore you.

Similar Threads

  1. Tax Refund Calculator......Need help finishing this code!!
    By txaviermars in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 25th, 2012, 12:16 PM
  2. Need help finishing my program
    By PapaMojo in forum What's Wrong With My Code?
    Replies: 5
    Last Post: April 8th, 2012, 01:21 PM
  3. Replies: 11
    Last Post: February 10th, 2012, 05:38 PM
  4. Need help finishing code. List Building...
    By Margaret_Girl87 in forum Object Oriented Programming
    Replies: 1
    Last Post: November 30th, 2011, 06:09 PM
  5. Beginner. Need Help finishing a simple Shoot em up game ASAP!!!!
    By cbock55 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 2nd, 2011, 08:13 AM