I'm working on a program to count the number of vowels entered by the user, but so far have been getting these 2 errors:
VowelsEnteredUntilFullStop.java:18: possible loss of precision
found : int
required: char
letter = keyboardIn.nextInt();
^
VowelsEnteredUntilFullStop.java:33: possible loss of precision
found : int
required: char
total = total + letter;
^
2 errors
The line in bold is the error being flagged.
// Practical 8 - Q6 // Marcus Ward // 07/11/2011 /* Program will allow user to repeatedly enter letters.Using a do-while loop and switch statement, the program will count the number of vowels entered until a full stop is entered. */ import java.util.Scanner; public class VowelsEnteredUntilFullStop { public static void main(String[] args) { Scanner keyboardIn = new Scanner(System.in); char letter = 1, vowel, vowelCount =0, total =0; // declare variables System.out.println("Enter a letter: "); // get user input [B]letter = keyboardIn.nextInt();[/B] do { System.out.println("Enter a letter: "); } while(letter != '.'); switch (total) { case 'a' : case 'e' : case 'i' : case 'o' : case 'u' : total = total + letter; vowelCount++; } System.out.println("The number of vowels is" + vowelCount); } }