This is due in 2 days its supposed to be simple but i just cant get it.

Write a program that will print out statistics for a user-specified number of coin tosses. First the user should be asked about the total number of coin tosses possible. For this project, the total number of coin tosses will be restricted to three choices (4, 6, and 8). If an incorrect choice is entered, display an error message and exit. If a correct choice is entered, the user will input either an ‘h’ for heads or a ‘t’ for tails for the number of user-specified number of tosses. The program will then print out the total number and percentages of heads and tails. Use the increment operator to count each ‘h’ and ‘t’ that is input. For example, a possible sample dialog might be


Please enter the total number of coin tosses (You have a choice of 4, 6, or 8 total number of coin tosses): 8
For each coin toss enter either ‘h’ for heads or ‘t’ for tails.
Enter toss #1 output: h
Enter toss #2 output: t
Enter toss #3 output: t
Enter toss #4 output: h
Enter toss #5 output: t
Enter toss #6 output: h
Enter toss #7 output: t
Enter toss #8 output: t

Number of heads: 3
Number of tails: 5
Percent heads: 37.5
Percent tails: 62.5

If anyone knows how to create this it would be greatly appreciated

i WILL DONATE A DECENT AMOUNT OF MONEY I CANNOT FAIL THIS CLASS... BUT I AM LOST... PLEASE HELP

THANK YOU
jUSTIN

Read this if you wish to receive any help.

Edit: Deleted taunt

When you get the number of tosses write if statements checking the validity of the information.

You must have variables where you count the successes and the failures

Then use a for-loop to print the:

"Enter toss #"+i+ "output: "

followed by the command for reading from the console.
Once you read the 'h' or 't', call a method that randomly calculates a coin toss. Then compare the value calculated with the one entered and increment one of the above variables if it was successful or not.
Then continue with the loop the same code,

At the end print the results.

The Math.random() generates a random number between 0 and 1. Use this to get a random coin-toss (if it is 0 - 0.5 the 'h' or if it is 0.5-1.0 't')

For reading from the console:

BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
String input = keyboard.readLine();

pseudocode

N = get number of tosses

  for (i=1 to N) {
print: Enter toss #i output:
get toss from console
calculate random toss
compare them
update score variables 
  }
print the results

This is what I got so far and I am really stuck dont know where to go ... this is a beginners class so it has to be simple didnt learn much so far.
This is what I got.........Using netbeans.... dont know where else to go to get outputs like this:::

Please enter the total number of coin tosses (You have a choice of 4, 6, or 8 total number of coin tosses): 8
For each coin toss enter either ‘h’ for heads or ‘t’ for tails.
Enter toss #1 output: h
Enter toss #2 output: t
Enter toss #3 output: t
Enter toss #4 output: h
Enter toss #5 output: t
Enter toss #6 output: h
Enter toss #7 output: t
Enter toss #8 output: t

Number of heads: 3
Number of tails: 5
Percent heads: 37.5
Percent tails: 62.5

Code:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cointoss;

import java.util.Scanner;

//This import will allow the keyboard to be active.//


public class Main {

    /**
     * @param args the command line arguments
     */
   public static void main(String[] args) {

        int heads, tails, NumberOfHeads, NumberOfTails, PercentHeads, 
                PercentTails, Output ;

        System.out.println("Please enter the total number of coin tosses" +
                "(You have a choice of 4, 6, or 8 total number of coin tosses): " );

        System.out.println("For each coin toss enter H ot T");

        Scanner board = new Scanner(System.in);

        Output = board.nextInt();





    }

}

This is what I got so far and I am really stuck dont know where to go ... this is a beginners class so it has to be simple didnt learn much so far.
This is what I got.........Using netbeans.... dont know where else to go to get outputs like this:::


Please enter the total number of coin tosses (You have a choice of 4, 6, or 8 total number of coin tosses): 8
For each coin toss enter either ‘h’ for heads or ‘t’ for tails.
Enter toss #1 output: h
Enter toss #2 output: t
Enter toss #3 output: t
Enter toss #4 output: h
Enter toss #5 output: t
Enter toss #6 output: h
Enter toss #7 output: t
Enter toss #8 output: t

Number of heads: 3
Number of tails: 5
Percent heads: 37.5
Percent tails: 62.5
_______________________________________________________________

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package cointoss;

import java.util.Scanner;

//This import will allow the keyboard to be active.//


public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

int heads, tails, NumberOfHeads, NumberOfTails, PercentHeads,
PercentTails, Output ;

System.out.println("Please enter the total number of coin tosses" +
"(You have a choice of 4, 6, or 8 total number of coin tosses): " );

System.out.println("For each coin toss enter H ot T");

Scanner board = new Scanner(System.in);

Output = board.nextInt();

}

}

I see no for-loop and I see nowhere where you read in how many tosses the user wants, unless it's this line:

Output = board.nextInt();

If it is, rename Output because it is a bad variable name. Name it numTosses or something.

You'll need a loop:

for (int i = 0; i < numTosses; i++)
{
     // ask for heads or tails and read in user's input.
}

Look at javaAddict's post and try to implement it. He's using N for numTosses , which is fine, but Output is a bad variable name for reading input.

You are doing nothing from what I suggested. You just wrote some commands without even knowing what they do. If you knew what they did you could just followed my advice and have a much better code.

You took the class a whole year and this was the best you could do?

is there any finished code for the problem stated above?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.