int wordpercent = ((count/totalwords)*100); JOptionPane.showMessageDialog(null, "Count: " + count); JOptionPane.showMessageDialog(null, "Words: " + totalwords); JOptionPane.showMessageDialog(null, "Character Count: " + length); JOptionPane.showMessageDialog(null, previousletter); JOptionPane.showMessageDialog(null, nextletter ); JOptionPane.showMessageDialog(null, "Your word makes up " + wordpercent + "% of the document");
This is the last part of my program. The program lets you select a text file, type out a word, and then finds how many times that word is in the document as well as how many characters and words are in the total document. I would also like it to show how much of a percent of the total document the typed in word makes. Everything works except for the wordpercent variable. It shows up as 0, even though the count and totalwords variables will have the correct numbers. If I flip it around and do (totalwords/count) I get a number as well, although the number isn't correct. Any ideas? An example would be, count shows up as 26 and totalwords shows as 340, then wordpercent shows up as 0.