Omg! I got it, thanks to you both. Why I added i++ to my if statements I'll never know, no duh it was adding an extra i, I did it manually! Face palming incredibly hard, feel like maybe someone drugged me before I coded this. Thanks!
Here is the completed code, works perfect!
/*
Paulino Rosado
10/3/2012
Computer statistics for eight coin tosses
*/
import java.util.*;
class Ch4Pa2
{
public static void main(String[] args)
{
int heads=0, tails=0;
double percentageHeads, percentageTails;
char tossresult;
String tempstring;
Scanner keyboard = new Scanner(System.in);
System.out.println("For each coin toss enter either h for heads or t for tails");
for(int i=1; i<=8; i++)
{
System.out.println("Toss "+i+": ");
tempstring = keyboard.next();
tossresult = tempstring.charAt(0);
if(tossresult == 'h')
{
heads = heads + 1;
}
else if(tossresult == 't')
{
tails = tails + 1;
}
else
{
i--;
System.out.println("Incorrect toss. You must enter either h or t");
}
}
System.out.println("Number of heads: "+heads);
System.out.println("Number of tails: "+tails);
percentageHeads = ((double)heads/8) * 100;
percentageTails = ((double)tails/8) * 100;
System.out.println("Percent heads: "+percentageHeads+"%");
System.out.println("Percent tails: " +percentageTails+"%");
}
}