Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Your task is to extract the meaning of some movie lines. The messages are actually codes that can be extracted by summing the secret //values of every vowel in the message. The values of the vowels are as follows: A = 65, E = 69, I = 73, O = 79, U = 85. The values apply for both upper and lowercase letters. For example, ‘I am Batman!’ has a total of 4 vowels: three times ‘A’ and one time ‘I’ andtheir //sum is: 3 * 65 + 1 * 73 = 268.
- import java.util.Scanner;
- public class Iluminati {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String text = scan.nextLine();
- text = text.toUpperCase();
- char[] textArray = text.toCharArray();
- int counter = 0;
- int sumOfVows = 0;
- for (int i = 0; i < textArray.length; i++) {
- if (textArray[i] == 'A') {
- counter++;
- sumOfVows+=65;
- }
- if (textArray[i] == 'E') {
- counter++;
- sumOfVows+=69;
- }
- if (textArray[i] == 'I') {
- counter++;
- sumOfVows+=73;
- }
- if (textArray[i] == 'O') {
- counter++;
- sumOfVows+=79;
- }
- if (textArray[i] == 'U') {
- counter++;
- sumOfVows+=85;
- }
- }
- System.out.println(counter);
- System.out.println(sumOfVows);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment