Win a copy of Murach's MySQL this week in the JDBC and Relational Databases forum!

Aj Prieto

Ranch Hand
+ Follow
since Sep 28, 2012
Aj likes ...
Android Chrome Windows
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Aj Prieto

It's because you have File directory set to null on line 17 rather than giving it a path.
9 years ago

Bashkim Ukshini wrote:

You should change the line on how you compute the average.

Remember, average = (sum of all elements) / (total number of elements)
9 years ago

Graham Wolk wrote:
I think I may be going in the right direction here. I can now work whatever numbers I put into the program, Ie = "Enter 4:45 / 60" result is "7".

Not quite, if you print out marathontimeasint, you'll notice that you're dividing 445 by 60, which isn't correct.

I think it would be easier if you calculated the total amount of minutes. After some math, you should end up with minutes / mile. (note: This would not be the final answer because it would be a decimal value rather than M:SS)

The example Campbell probably wants you to look at is towards the top of the page of the Scanner documentation. (hint: The example talks about fish).
9 years ago
In the cmd line, enter
10 years ago
Try to check your JDK version, there's usually an underscore somewhere in there.

For example mine is:
C:\Program Files\Java\jdk1.7.0_21\bin
10 years ago

Ishan Pandya wrote:Look this code.. I have made a skelleton for you.. Includes some varaibles and println to complete it..

Hope it helps.

First off, that code wouldn't compile.
There is no .length() method in the array class and your variable "y" is already defined in your parameters, so you can't use that in your "for" loop.
Overall, the skeleton you provided seems way more complex than what is required.

You're meth1 looks closest to being correct. You just have to reset the count variable and I would print the result before closing the first "for" loop.
10 years ago
You have to reset your count variable each time the outer loop increments.

What's the purpose of "meth2"? And please try to come up with better names for methods.

It is possible to do what you want to accomplish with one method (getting the count and printing it to the screen).
This could be done by adding the line:
10 years ago
You could probably do something like this.

Also if you look in the example you posted, you're missing index 3 for your prices array.
10 years ago
Right now, you're using the loop variable and not the values contained in your array.

You need to access the values of the array.

It also looks like you're not checking if it is >= 1582.
Note: I haven't really looked over the logic, so I'm not sure if it's doing what its supposed to.
10 years ago

sam detweiler wrote:
my conclusion remains, unless someone says.. use method foo().. that I will need to make some additional coding of some sort or another.

In my post, I pretty much said to use method foo() (read it again carefully).
10 years ago
Check the String class, there's a method in there that tells you if a string "contains" another string you are looking for.
10 years ago
First off, read this WhatNotHow.

Next, I'm curious, why not just use doubles?

That way, you don't have to deal with multiple numbers. All you'd do is manipulate one value rather than two.
10 years ago

Taylor Lynn wrote:I thought i was using the scanner class when i implemented
Scanner scanner = new Scanner(

You created a scanner object, but you're not actually reading in anything from the user.

Taylor Lynn wrote:I'm also using the nextInt method from the scanner class on line 20.

They way you have it is incorrect. You're setting a value equal to it rather than a variable.

The nextInt() method takes in an int from the user and sets it to a variable.

10 years ago
I think line 20 in the first code is causing your problem.

Reading in the user input shouldn't be too big of a problem, you could just use the Scanner class.
10 years ago