Hi java masters,
Problem with the loop where I'm not able to trace it in memory - looking for some advice/hint.
Program prompt the user to enter a line of text and then it iwll count how many occurrences there are of the letters a,e,i,o, and u regardless of case.
****** problem is that I'm getting the right answer when I will remove //A and leave only a++ and by leaving as SOP(a); , when I add SOP(a+A); than I'm getting weird results. I can't trace the memory and can't find jgrasp option to show the memory so I created this loop with trials and errors.
This is what I have so far:
import java.util.Scanner; public class test { public static void main(String [] args) { Scanner keyboard = new Scanner (System.in); String input; int a,e,i,o,u,A,E,I,O,U; int countOne, countTwo, countThree, countFour, countFive, numVawels, size; //a, e, i, o, u; System.out.print("Enter a line of text: "); input = keyboard.nextLine(); //size = input.length(); a = 0; A = 0; e = 0; E = 0; i = 0; I = 0; o = 0; O = 0; u = 0; U = 0; countOne = 0; countTwo = 0; countThree = 0; countFour = 0; countFive = 0; while(countOne<input.length()) { if(input.charAt(countOne)=='a'||input.charAt(countOne)=='A')//||input.charAt(count)=='e'||input.charAt(count)=='i'||input.charAt(count)=='o'||input.charAt(count)=='u') a ++; A ++; countOne ++; } System.out.println(a+A); while(countTwo<input.length()) { if(input.charAt(countTwo)=='e'||input.charAt(countTwo)=='E')//||input.charAt(count)=='e'||input.charAt(count)=='i'||input.charAt(count)=='o'||input.charAt(count)=='u') e ++; E ++; countTwo ++; } System.out.println(e);