This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Grokking Bitcoin and have Kalle Rosenbaum on-line!
See this thread for details.
Win a copy of Grokking Bitcoin this week in the Cloud/Virtualization forum!

Sankalp Bhagat

Ranch Hand
+ Follow
since Oct 14, 2015
Cows and Likes
Cows
Total received
-1
In last 30 days
0
Total given
0
Likes
Total received
5
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Sankalp Bhagat

sai rama krishna wrote:

you mean like above add space beore printing the number in the for loop?

i got below wrong output


Please enter number:
126
 
1
 
2
2
 
6
6
6



You got confused with my comment because that was modified by one of the moderators. My original comment was deleted.
Anyways, see the difference between print() and println() methods. You are printing both spaces and digits so you have to adjust your code according to your need with perticular spaces in between
2 years ago

Lexi Turgeon wrote:Couldn't I just change the "parseCard" method to static?


Yes you can change it to static. Then you can directly call the parseCard method from main method without creating an object of the class where the parseCard method is declared as the context of both the methods is static.
2 years ago
The method "parseCard" that you want to call from "main" method is non-static. And as "main" method is static, it won't allow to call a non-static method from there. Thus, you need to create an object of the class where you have written that parseCard method. and from that object, you'll have to call the parseCard method. And as the parseCard method returns the object of Cards class. you need to take the result in Cards object such as
2 years ago
Instead of using all those if statements you could use a single for loop.



And to call that method from main method, you have to create an object of the class where you have written that method as the method is non-static method and you are calling it from the static context as main method is static. And then call that method from that object reference and as your method is returning Cards object you have to assign the result the Cards.
such as
2 years ago
You could try something like this
2 years ago
I haven't read the API but from the line given by you

a static method getSequencer() is declared in MidiSystem class whose return type is Sequencer. So, when you call getSequencer() method, it returns Sequencer class's object. Thus, you have to hold that object in a reference. That's why you are taking "Sequencer sequencer" to hold the returned Sequencer object in a reference variable called "sequencer"
2 years ago
If you want to store Vector object references, you should store it in a list.
You can write like this and iterate the list and you will get Vector objects

Tapas Chand wrote:Hi Sankalp, I think moderators will agree with me that it is not a good thing to provide a working code as a solution. OP should get the solution by brainstorming himself/herself.

Hi Emily, You want to add the even values, but you are making "counter" a odd value in line 31 and 37 and using that to add the values, so you are getting wrong output.


Hello Tapas, it's not a solution to her problem. It's the simple use of while loop. that small code nowhere related to her logic. If she understands the use of while loop from what I've provided, she can herself modify her own code
3 years ago
Don't use BufferedReader class here. Use Scanner class instead.
There's a problem in line no. 11 and 12. You are taking input first and then asking.
You can write using Scanner as
3 years ago
You need to learn Map interface also along with Collection interface and Generics concept too.
Below links are much helpful

Collection

Map

Generics
3 years ago
First of all Welcome to Ranch Emily
You can use something like this while loop for counting even integers between two numbers if the first number is smaller than second one..

3 years ago
JOptionPane.showMessageDialog(null, "Registered successfully");
3 years ago
Use JOptionPane
3 years ago
So am I... I'm as well learning and helping a little bit if I can... No one is proving anyone's knowledge
3 years ago
If you had to reply to his post you should have replied to his not mine because I was replying to the original post.
3 years ago