I've already looked in this thread:
StringIndexOutOfBoundsException String index out of range: 0
But checking the length did not fix the issue. I'll just post my entire program here, it's not long yet. I cannot think of what the problem is...
import java.util.*;
public class Project2_Mazzone {
public static void main (String [] args)
{
Scanner scan = new Scanner (System.in);
String gender;
double drinks, weight, hours, age, alcMetabolized, ratio, limit;
char letter;
System.out.println("Welcome to the BAC calculator!");
System.out.println();
//Gathering info from the drinker & setting values accordingly
System.out.print("How many drinks have you had? ");
drinks = scan.nextDouble();
System.out.print("How much do you weigh (in pounds)? ");
weight = scan.nextDouble();
System.out.print("How many hours ago did you start drinking? ");
hours = scan.nextDouble();
alcMetabolized = .015 * hours; //Stores value for alcohol metabolized
System.out.print("Are you a male or a female? ");
gender = scan.nextLine();
letter = gender.toUpperCase().charAt(0);
if(letter == 'M'){ //Stores value for ratio based on gender
ratio = .66;
}else{
ratio = .73;
}
It's showing me this error before I even press anything on that line:
http://gyazo.com/60f1cd4fe4e0718c0c8264bfd4049be3