# 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 numtails = 0;
float numcointosses = 0;
float correct = 0;
float incorrect = 0;

int toss, coinguess, randomguess;

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)
{
coinguess = 1;
}
else
{
System.out.println("Random Guess is Tails");
coinguess = 2;
}
}
if (toss == 1)
{
}
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