Java program of Vowels in a FishBowl

Question:-

Steffi plans a game to teach her students about vowels . There are 5 students .Steffi places 25 slip of papers in a fishbowl, where each slip contains a word.Each student has to take 5 slips and count the number of vowels in each slip and write it in a paper consecutively.

The Points are given as below

No of VowelsPoints
10
21
33
44
56
More than 58

A student who gets the highest point is considered the winner. When no point is scored by anyone then display “No one has got any points”.

Sample input 1

mango basket ball auspicious kangaroo

precaution misbehavior battery cup screen

parasite hello good come education

invitation squeeze paper ant multiplication

COOPERATION DEMOCRACY CONGRATULATIONS YOU BYE

Sample output 1

1 1 0 8 4

6 6 1 0 1

4 1 1 1 6

6 4 1 0 8

8 3 8 1 0

1 14

2 14

3 13

4 19

5 20

The winner is student 5 with points 20

Code:-

Main.java

import java.util.*;
public class Main 
{
    public static void main (String[] args) {
        
        char vowels[]={'A', 'E', 'I', 'O', 'U'};
        //String vowels[]={"A", "E", "I", "O", "U"};
        String input[][]=new String[5][5];
        
        Scanner sc=new Scanner(System.in);
        String ip[]=new String[5];
        for(int i=0; i<5;i++)
        {
            
            ip[i]=sc.nextLine();
            
            input[i]=ip[i].split(" ");
        }
        
        
        
        
        int vowel_count[][]=new int[5][5];
        int count=0;
        for(int i=0;i<5;i++)
        {
            for(int j=0 ; j<5;j++)
            {
                for(int k=0; k<5;k++)
                {   
                    char temp=vowels[k];
                    for(int l=0; l<input[i][j].length(); l++)
                    {
                        if(temp==Character.toLowerCase(input[i][j].charAt(l)) || temp==Character.toUpperCase(input[i][j].charAt(l)))
                        {
                            count++;
                        }
                    }
                }
                vowel_count[i][j]=count;
                count=0;
            }
        }
        
        int score[] =new int[5];
        
        for(int i=0;i<5;i++)
        {
            for(int j=0;j<5;j++)
            {
                if(vowel_count[i][j]==1 || vowel_count[i][j]==0)
                {   System.out.print("0\t");
                    score[i]+=0;
                }
                else if(vowel_count[i][j]==2)
                {   System.out.print("1\t");
                    score[i]+=1;
                }
                else if(vowel_count[i][j]==3)
                {   System.out.print("3\t");
                    score[i]+=3;
                }
                else if(vowel_count[i][j]==4)
                {   System.out.print("4\t");
                    score[i]+=4;
                }
                else if(vowel_count[i][j]==5)
                {   System.out.print("6\t");
                    score[i]+=6;
                }
                else
                {   System.out.print("8\t");
                    score[i]+=8;
                }
            }
            System.out.println();
        }
        
        
        int max=0;
        String max_index=new String();
        for(int i=0;i<5;i++)
        {
            System.out.println((i+1)+"\t"+score[i]);
            if(score[i]>max && score[i]!=0)
            {
                max=score[i];
                max_index=max_index+"student "+String.valueOf(i+1)+" ";
            }
            else if(score[i]==max && score[i]!=0)
            {
                max_index=max_index+"student "+String.valueOf(i+1)+" ";
            }
            
        }
        
        if(max!=0)
        {   
            System.out.println("The winner is "+max_index+"with points "+max);
        }
        else
        {
            System.out.println("No one has got any points");
        }
    }
}

Recommended:-

  1. Array square
  2. Generate number using odd digits
  3. Alternate Number Difference
  4. Next Greatest number
  5. Mark Comparison
  6. Print the characters in descending order
  7. Vowels in a fishBowl
  8. Least offer
  9. Ascending and descending order
  10. Mail Domain
  11. Count repeating words
  12. Sentence – Convert to upper and lower
  13. Count consecutive repeating characters
  14. Zig zag Array
  15. Pass and Fail Count
  16. Search a Course
  17. Average and Grade Calculation
  18. String – Find and replace the character (first occurrence)
  19. Sort the first and second half of an array
  20. Retail Shop
  21. Palindrome
  22. Numerology
  23. InitCap
  24. Array Compatiblilty
  25. Sum of the maximum and the minimum element
  26. String Concatenation
  27. Find Average Age
  28. Login
  29.  

Leave a Comment

Your email address will not be published. Required fields are marked *

x