Skip to main content

Posts

Showing posts from May, 2020

Write a Java program to input a sentence and print those word which do not contain any vowels and also count those words

Question: Write a Java program to input a sentence and print those word which does not contain any vowels and also count those words. Welcome to Programming Chaska !!!. In this post, I will share the code  to input a sentence and print those word which does not contain any vowels and also count those words . This question is recently asked in google question hub, so in this post, you will get its solution. Sample Input 1: Enter Sentence: I am seeing a post from the Programming Questions blog. Sample Output 1: All the words in the above sentence contain vowels Number of words which does not contain any vowel = 0 Sample Input 2: Enter Sentence: The rhythm and flow of this song are quite decent. Sample Output 2:  rhythm Number of words which does not contain any vowel = 1 Solution code: import   java.util . Scanner ; public   class   consonantWords  {      public   static   ...

Which data type is appropriate to store age of person?

Which data type is appropriate to store the age of the person? I will clearly say that to store the age of the person, the appropriate data type is an  int data type. However, if you are trying to reduce space complexity, I will say that you should go for byte data type as it has a range of -128 to 127. On the other hand, int data type ranges from  -2,147,483,648 to 2,147,483,647.  So byte data type would be perfect as the age of a person is more likely to be smaller than 127 (the maximum number which a byte data type can store).  I would generally prefer int data type because of the following reasons: We should not use float data type to store age as it would be inappropriate because the age of a person is generally preferred in numbers and not the decimal format. For Example, We say that the Age of a person is 18 rather than saying that that the age of the person is 18.0 or something like that. We should not use the String data type as it would be tri...