last day (15 days later) » 

8:20 PM
0
A: Procedure Method, counting vowels

StackFlowedWhat you have is fine just some improvements. import java.lang.String; import java.util.*; class VowelCount{ static int countVowelA=0,countVowelE=0,countVowelI=0,countVowelO=0,countVowelU=0,countConsonants=0; public static void main(String args[]){ Scanner sc = new Scanner(Syste...

 
why a down vote ?
 
A method should be reusable. A method should not use System.out.println unless it's for debug purposes or purely for presentation purposes, or even better, use a logger instead. A method should return an object that stores the result of processing the input, or return nothing in case you should not have any output. The client should decide what to do with the data returned from the method.
A method should also have a single purpose. If a method will perform multiple actions, then it should call 2 methods and use proper variables to orchestrate the call and usage of the other methods.
 
@LuiggiMendoza Check the edit !
 
It's slightly better. Now I have to ask: why do you moved the variables into static fields? While it solve the problem, calculating the vowels of a second word will fail.
 
That is out of the scope of main you would have to re run the program ! I did it cause i didn't want to return a array of the int or write a another class which would have the count ... and use that !
Hi
 
8:20 PM
hello @StackFlowed
 
@LuiggiMendoza
 
I read your last comment and you're half right
 
How else would you suggest to return 6 integers ?
 
because we don't know if OP knows how to use arrays
but yes, an array would be a proper way
 
Yes and since this is basic I kept it that way !
 
8:21 PM
or even a Map<Character, Integer>
 
FYI I would have preferred a switch instead of if and else if 's
 
yes
or even regexp
 
Yup !
 
and it becomes more complicate
and more and more...
anyway, but for learning purposes
that's not a good design as well
 
Agreed there are multiple ways to do it but simpler to read is the best way !
 
8:23 PM
other thing we could do is
I guess there's a line between simpler and too simple that even allows a bad design
which is my reason for downvoting
 
Yes i understand that but we need to understand that OP is also a beginner. If you see OP code OP is using another variable when they can add all five to get total cont that tell me OP is beginner and not an expert hence I didn't get it too much of design and other concepts. If you are satisfied with the answer can you get rid of the down vote !
 
no, I'm not satisfied
if other people think you're right, then they will upvote you
but when I see an answer with bad design, I cannot support it
and depending on how you explain your post
then I can provide a comment or something else
for example, you just provide a simple piece of code
with formatting and moving some part of the code to the main
if that's enough for you, it's ok
but I like to also provide an explanation of why this is a proper approach
 
Since you feel that design is such a big part of the code i would like to see an answer from you !!!
 
I was writing it, but then wild answer appeared and was marked as accepted
so I deceived mine
 
So does this mean if they have to accept your answer or you will mark all other as down voted ?
Just to let you know this is a design question ... It just a general question !
 
8:33 PM
no, that's not what I mean
if you provide an answer, is fine
if somebody else does it, is fine as well
but if the answer (regardless the user that post it) doesn't meet a quality standard or, as the downvote hint states, This answer is not useful
then you're free to downvote it
in my case, I didn't find your answer useful in its first state
so I downvoted
now it has a bug that it's a single execution app
so IMO it's still not useful for future readers
but if you're ok with it, then just move on
there will be more questions to answer
and if IMO they are good, then I'll upvote
if you provide answers that IMO have good quality, then I'll upvote
 
Ok !
now it has a bug that it's a single execution app --> this is out of main ...
 
it means your answer has some bugs and shouldn't be accepted that easily
 
I really don't know what you are talking about how is it a bug that is not in my code !
 
which is OP's fault
but that's outside this chat
 
Have a nice day out of here !
 
8:39 PM
you too, pal
cya around
 

last day (15 days later) »