• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Matrices program

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I'm trying to write a program which multiplies two matrices but I don't manage to make it work.
Could you help me correct the errors ?

Thank you
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't put so much code in the main() method; that code should be elsewhere. I suggest you start with a Matrix class; consider whether it should contains integers or fractional numbers. Give that class methods like add(), subtract(), etc.
If the two matrices are the wrong size to multiply, throw an IllegalArgumentException.
 
Rancher
Posts: 5008
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

 help me correct the errors ?


Please copy the full text of the error message and paste it here.
 
Campbell Ritchie
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is incorrectly indented. Look at line 37, for exmple. You should decide on an indentation convention and stick to it. Otherwise it will be impossible for you to tell which piece of code is where. Go back to your code and indent it correctly, and some of the errors will become clear.
 
Saloon Keeper
Posts: 10705
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Indentation is critical to finding errors. If you are using an IDE (e.g. Eclipse) it more than likely has a built in code formatter. In Eclipse you select the code you want to format and press  Ctrl-Shift-F. If you are not using an IDE then you may want to check out the post for Indentify, a rudimentary indenter.

In java you are not permitted to define one method inside another method.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic