I have to read in a file to my project and then read the file line by line to find the percent of upper case and lower case letters. My output should be 4 lines stating the percent of upper and lower for that specific line in the file. This is what I have to far but it doesn't quite work:
    Scanner inFile = new Scanner(new File("file.txt"));
    int upper = 0;
    int lower = 0;
    int total;
    double percentU = 0.0;
    double percentL = 0.0;
    while (inFile.hasNext()) {
        String line = inFile.nextLine();
        for (int x = 0; x < line.length(); x++)
        {
            if (Character.isUpperCase(line.charAt(x)))
            {
                upper++;
            }
            if (Character.isLowerCase(line.charAt(x)))
            {
                lower++;
            }
        total = upper + lower;
        percentU = upper/total;
        percentL = lower/total;    
        System.out.println("lowercase: " + String.format("%.2f", percentL) + "\t" + "uppercase: " + String.format("%.2f", percentU));
        }
    }
 
     
     
    