This week's giveaway is in the Spring forum.
We're giving away four copies of Microservices Testing (Live Project) and have Chris Love & Andres Sacco on-line!
See this thread for details.
Win a copy of Microservices Testing (Live Project) this week in the Spring forum!

Carey Brown

Saloon Keeper
+ Follow
since Nov 19, 2001
Carey likes ...
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
Forum Moderator
Carey Brown currently moderates these forums:
Colorado, USA
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 Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carey Brown

Create three methods:
1. inchesToCentimeters() takes the number entered by the user, and returns the
result of the number multiplied by 2.54.

In your requirements it shows the name of the method you are to create, "inchesToCentimeters". It shows an empty parameter list, "()", but NOTE that this is often shown as empty but is left for you to figure out what, if any, parameters will be required. In your case the parameter is specified in your requirements. Note that the return type is also not shown but it is specified.

You can google tutorials on how to create methods: java method tutorial

Heres one:
1 day ago
Welcome to The Ranch Leorio !

When posting code to this site we ask that you UseCodeTags (<-link for you to read). It adds line numbers and preserves indentation. In order for it to work do NOT un-check "use BB tags" below the post.

I fixed it for you this time.
1 day ago
After much reading I came across this and it seems to do the trick.

2 days ago
I have a game with a digit appearing in some of the board grid cells. I want to automatically position the digit centered in the cell using font metrics. Being a digit the character has no descendor. This is my attempt which only behaves correctly for the X positioning, but not for Y. I've tried variations on the formula for Y but none of them behave consistently if I change CELL_SIZE. I haven't tried actually changing to a different font yet but I'd like the formula to work with that as well. I thought I could ignore the descent size but now I'm not so sure and it's not clear how I would use it in the formula.

2 days ago
This can be read as:
foreach String 'element' in the list 'al'
2 days ago
As I said, your first test doesn't work.

Your second test only compares a single digit past the period.
3 days ago
Comparing the length doesn't tell you anything. What if you have "12.3456" and "1.23456"?

You could use  indexOf() to find the period and then substring to get only the characters to the right of the period.
3 days ago
I'm closing up shop here for the night.

You need to create a new directory for your Buttons project that is not inside C:\Program Files. For example make a Java folder then

And put your source code in it

And compile it:
cd \Java\Buttons

5 days ago
Ah, I needed to be more explicit. What if you enter:

cd \
java -version
5 days ago
If this is your path to your project then you have a problem. A user should never put anything inside C:\Program Files.
C:\Program Files\Java\jdk-14.0.2\bin>java

On your command line, if you enter
java -version
what do you get?
5 days ago
Seems like a maintenance nightmare that you're leaving behind for your successor.
5 days ago
Changed subject heading to be "Java Swing" because that's what you're using, not "Java AWT". Hope this helps.
5 days ago
You only have one each of appleX and appleY, you'd need an array or List of each. Then in draw() you'd need to loop through them and draw your apples.

Also note that in this code the appleX and appleY are local variables so executing this method essentially does nothing.

5 days ago