# JAVA IN FINISHING SOMETHING

• February 18th, 2013, 09:42 PM
komal510
JAVA IN FINISHING SOMETHING
import java.text.DecimalFormat;
import java.util.Locale;
import java.util.Scanner;
import java.text.*;
import java.io.*;

class CoinToes
{
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";

Decimalformat pf2 = new Decimalformat ("###.0##");
Scanner input = new Scanner(System.in);
{
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)
{
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
• February 18th, 2013, 09:47 PM
curmudgeon
Re: JAVA IN FINISHING SOMETHING
Quote:

Originally Posted by komal510
... 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.