Helen Keyes
2012-01-20 18:40:54 UTC
These are the instructions:
Write a program to calculate the probability that a family with two children
will consist of two boys, a boy and a girl, or two girls.
I have a .txt file with the data and I can import it, I just don't know what to do from there.
THANKS!
ps here is the program I have so far:
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
public class TextFileReader
{
public static void main(String[] args) throws IOException
{
String token = "";
File fileName = new File("MaleFemaleInFamily.txt");
Scanner inFile = new Scanner(fileName);
while (inFile.hasNext())
{
token = inFile.next( );
System.out.println (token);
Scanner in = new Scanner(System.in);
System.out.println("What is the size of the sample?" );
int samplesize = in.nextInt();
int twoBoys = samplesize/10;
int twoGirls = samplesize/10;
int oneBoneG = samplesize/10;
System.out.println("Sample Size: " + samplesize );
System.out.println("Two Boys: " + twoBoys);
System.out.println("One Boy One Girl: " + oneBoneG);
System.out.println("Two Girls: " + twoGirls);
}
inFile.close();
}//end of main method
}//end of class