Okay, first off, hello to all. I am a mechanical engr. student, and am in a intro Java class. This is my first experience with programming of any sort, so I really have no idea what I am doing. Alot of monkey see, monkey do right now. I have a program, coin toss, which I am sure alot of you have seen. I have the bulk of the program functional, just the final portion, where it tallies the heads and tails, and calculates a percentage for both. I have copied and pasted, (the attach file wasn't working for me) what I have got so far, can someone please take a look and tell me (in a very slow, childlike manner) what I am doing wrong? i have highlighted in red what I think the problem areas are, but I can't figure out how to fix it. Thank you.
Nick the New Guy.
import java.util.Scanner;
public class CoinToss
{
public static void main (String [] args)
{
int headCount = 0;
int tailCount = 0;
float percentHeads = (headCount++) / 8 * 100;
float percentTails = (tailCount++) / 8 * 100;
char tossResult;
System.out.println ("Flip a coin a total of eight times.");
System.out.println ("After each flip, enter the value of the flip,");
System.out.println ("use 'h' for heads,");
System.out.println ("and use 't' for tails.");
System.out.println ("The program will keep track of the number of 'Heads',");
System.out.println ("the number of 'Tails', and the percentages of each.");
System.out.println ("What is the first value?");
Scanner keyboard = new Scanner (System.in);
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("What is the second value?");
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("What is the third value?");
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("What is the fourth value?");
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("What is the fifth value?");
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("What is the sixth value?");
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("What is the seventh value?");
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("What is the eigth value?");
tossResult = keyboard.next().charAt(0);
if(tossResult == 'h');
headCount++;
if(tossResult == 't');
tailCount++;
System.out.println ("The total amount of 'Heads' entered is:");
System.out.println ("headCount + " headCount++");
System.out.println ("The total amount of 'Tails' entered is:");
System.out.println ("tailCount + " tailCount++");
System.out.println ("The percentage of 'Heads' is:");
System.out.println ("percentHeads + percentHeads");
System.out.println ("The percentage of 'Tails' is:");
System.out.println ("percentTails");
}
}