Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search Coderanch
Advance search
Google search
Register / Login
Sven Eriksson
Greenhorn
+ Follow
news
1
Posts
0
Threads
since Oct 20, 2011
Merit badge:
grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads
Recent posts by Sven Eriksson
Trying to get rid of redundancy?
Hi Ashley
Easiest would be something like this:
System.out.print("What is the y coordinate? "); double y = console.nextDouble(); if (x < 0.0) { if (y < 0.0) { negatives = 2; } else { negatives = 1; } } else { if (y < 0.0) { negatives = 1; } else { negatives = 0; } } System.out.println("negatives = " + negatives); return x + y + negatives;
Hopefully that might help some, but you could also write it in another method and call to it
Remember, everyone codes differently...
show more
13 years ago
Beginning Java