• Post Reply Bookmark Topic Watch Topic
  • New Topic

How would I compare the results of two different methods?  RSS feed

 
Abe Gill
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


So going diagonally both ways, the total is 15. I want to print a statement that would compare whether or not these numbers equal 15, and if they don't, I'd like to return a statement that says "it does not equal 15". Now I'm trying to use an If/Else statement but the problem I'm having is when I go to compare the methods, it says the variable does not exist. Here's what I'm trying..



Ideas? Also, is there a smarter way to find out the sums and totals of each column/row? For the 3x3 square I ended up writing 8 methods.
 
Pete Letkeman
Ranch Foreman
Posts: 912
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is your prolem

The method diagonal2 expects an array and you are not passing that in. What if you did this:
 
Pete Letkeman
Ranch Foreman
Posts: 912
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And don't be like me, I forget to put the opening brace bracket "{" after the "))".
 
Abe Gill
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pete Letkeman wrote:This is your prolem

The method diagonal2 expects an array and you are not passing that in. What if you did this:



Thank you sir, you're the best.
The syntax is a little confusing, our teacher has us doing this all in a notepad.
 
Pete Letkeman
Ranch Foreman
Posts: 912
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good to see that it's working.

There are reasons to use an editor such as Notepad, however there are much better editors out there such as Notepad++. That being said you don't always have a choice, especially if someone else is showing/instructing you like a teacher.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!