Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

Miljan Puletic

Greenhorn
+ Follow
since May 19, 2016
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
2
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 Miljan Puletic

I have completed Stanford`s Java Programming methodology. I did it in 4-5 months with relatively high level of thoroughness. I did 6 out of 7 big assignments, did all homeworks, read couple of times course reader The Art and Science of Java by Eric Roberts etc. Since the title is almost self-explanatory, how do I proceed further ? 

I decide not to go for CS106B (C++ course), but rather to continue developing Java skills.

Somehow I think that tutorials are not giving you much of practice versus books. So my thoughts are to start with some good book, where there are good programming assignments, small and big ones, easier and more difficult...After reading this https://coderanch.com/t/675389/java/developing-java-skills-read-HeadFirstJava, somehow it seems that HeadFirst is my natural choice. Although, after I looked at several chapters of the book, it seems that it does not have enough assignments and concrete tasks. But on the other hand, that book gives very nice theory and I prefer that style of writing.

What would you guys do, all suggestions are more then welcome.
1 year ago
Thnaks, I got it now.
1 year ago
I have no idea why I am I getting prompt "ArrayIndexOutOfBounds" ?? Maybe is something benign, but I just dont see it. The console prompt is also telling my to look at line number 16, but again I think that my logic is ok. Can someone tell me where is the problem ?

1 year ago
This is not a code-related question but rather what to do next.

I`ve been studying Java from Stanfords lectures channel and studying from the book The Art and Science of Java by Eric Roberts. I have been studying it thoroughly for well almost five months (I know it`s super small amount of time...) beside that I have been doing homeworks and all other necessary assignments (for instance we have made the Breakout game) with complete understanding of what had been asked. I did my best and I`ve learned a lot! Now I understand the concepts, but I am not sure in myself in the sense whether I am good enough to start implementing that learned knowledge into something useful such as building mobile apps. My goal is to learn Java just enough so that some company would take me as an (unpaid) intern. How to scale my knowledge ? What should I learn next ? How to determine how far I am from junior position ? 


1 year ago
Where I can find good tutorial about Wrapper classes ? Not including Javadoc
1 year ago
Can anyone recommend a good book for algorithms and data structure for beginners ? By beginner, in this case, I mean a person who is learning programming in java for 6 months, taking some university courses in java programming, read thoroughly couple book such as "The Art and Science of Java" - by Eric Roberts (along with Stanford lectures), "Think Java - How to Think Like a Computer Scientist" - by Allen Downey etc.

P.S.

My apologize up front if, there has been already similar topic opened somewhere on this forum, I couldn't find it.
1 year ago
As I saw here on this forum, there are couple of posts that are dealing with the Bouncing ball program, where people are posting what they cannot figure out. I'll do the same, but I will also try to hit the core problem of this programming assignment and make the best effort to try to explain what I can't understand, since I am very new at this.

The code in question is from CS106A lectures at Stanford. Here`s the code:



As I can see, from the while loop, the logic is to move the ball, check to see if there is collision with the bottom of the screen, if no, do the pause, in order to get animation effect and continue in this order until you hit the bottom. The moveBall() method tells me, on each iteration, increase ball`s velocity in Y direction (downwards) to get the acceleration effect due to gravity. Now, in order to move the ball, the move() method must be called upon object, that is the ball. move(dx, dy) method, by it`s definition tells: move the object dx and dy pixels from its current position.

Now comes the funky part, as the lecturer of the course mentioned above would say. The checkForCollision() method. If the condition ball.getY() > getHeight() - DIAM_BALL, is true, that means, if I understood correctly that ball is touching the bottom of the screen and the thing that should happen next is bouncing, or simply the ball needs to bounce off the bottom.

So, the process or the action of bouncing, requires the ball to change the direction of the ball, so now the yVel has the negative sign and it (ball) retains 90% of its previous speed. What I don`t understand is how the ball is actually moving upward ? If we look at the moveBall() method, I can see that the effect of moving is happening because of ball.move(xVel, yVel) + the pause(DELEY) in the while loop. But in checkForCollision() method the code defines the necessary Y velocity and its direction in this code line yVel = -yVel * BOUNCE_REDUCE, I don`t see how and where is that yVel implemented ??? I don`t understand the effect of moving upwards! How does the yVel behaves in this program since it is an instance variable ?

One more thing, what tells us how far will the ball bounce, that is how to know when to start falling down again ? 

1 year ago

Julian West wrote:
*ahem*

*cough-cough*



Sometimes I hate myself.



The program now works fine. Thanks Julian.
1 year ago

Jesper de Jong wrote: What is it exactly that you're having problems with?



Sorry I wasn't specific enough. So, the main problem with this program is that it is not calculating the correct average for some reason. For instance, if I enter hex number FFFF and the next number 1 also as hex, their average in decimal notation should be 32768, but I am getting some completely different value.

Jesper de Jong wrote:  I don't know what the readLine method that you use in line 15 returns if you enter "blank space"



By "blank space" I mean Enter, the user doesn't enter a number or blank space, just hits Enter. When the user hits Enter button the readLine method should "direct" the program to the else part in while loop.


About that equals method, since this is my first time using it.

If I understood this right, the equals method asks whether the object contains the same sequence of characters ? If it does, the the method sends back the result of comparison as true or false.

I am not really sure what this line of code does:



What does this expression returns true orfalse ?

1 year ago
I have to write a program that uses static methods Integer.parseInt and Integer.toString which will convert hexadecimal values into their decimal equivalents and then calculate the average value of those decimal equivalents. The program should read hexadecimal values until the user enters blank space as a sentinal value.

The problem is that I don't know how to deal with x value since it is a string. How to set blank space as some sort of condition ? I have tried to write this program in few different ways, this one is the last version. Also, am I asking myself the "right" question, regarding condition which to set and how to think while solving these kind of assignments ?



1 year ago

Knute Snortum wrote: Good job!


Thanks! It means a lot to a new programmer. I will adopt your advises.

fred rosenberger wrote:I would argue your isPrime method is not correct. It will return false for the input value of "2"


I will just write one more if statement. 

Fred Kleinschmidt wrote:Why include x in the loop if you are just going to subtract it later? 


I've already did what you suggested, just I haven't posted here. But thanks anyway.
1 year ago
I did it guys!!! Woo hoo


   
   

1 year ago
In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself (also known as its aliquot sum). Equivalently, a perfect number is a number that is half the sum of all of its positive divisors (including itself)

After looking at definition of a perfect number I've modified code, so that it looks like this, but again I am getting the wrong results.

1 year ago
I have to write a predicate method isPerfect(x) that returns true if the integer x is perfect, and false otherwise. I need to test this implementation by writing a main program that uses the isPerfect method to check for perfect numbers in the range 1 to 9999 by testing each number in turn. Whenever it identifies a perfect number, program should display that number on the screen. The first two lines of output should be 6 and 28.

I have tried to combine isPrime metohd with this program, but for some reason I am getting bunch of numbers from 1 to 9999. I don't know whether my thought process is bad or I might just overlooked something.

1 year ago
Hi Carey,

Since I am complete newbie, would you be willing to explaint a little bit more what these print statements do, I dont quite understand how those print statements determent which number is greater and which is smaller.
1 year ago