Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Reducing A Matrix Into A Reduced Row Echelon Form

 
Ranch Hand
Posts: 130
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Am currently working on a project from JetBrains Academy which requires me to read a file containing a matrix and reduce it into reduced row echelon form.
The project requirement can be found here https://hyperskill.org/projects/40/stages/211/implement

This is my current implementation, it only reads the file into two dimensional integer array.

Any recommendations to make the current implementation robust will be appreciated.



This how the content of the file looks like
The first line determines the row length of the matrix
3
1 1 2 9
2 4 -3 1
3 6 -5 0

Thank you.
 
Sheriff
Posts: 16578
277
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would have used a Scanner and Scanner.nextInt() to eliminate the need to do readLine.split() and Integer.parseInt()--that's just too much hoop-jumping for my taste.
 
Saloon Keeper
Posts: 4611
182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing wrong with your code, but I would use this:

The method Files.lines may throw an IOException, so either this code must run in a try/catch block, or the method must be declared to throw such an Exception.
 
Piet Souris
Saloon Keeper
Posts: 4611
182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oops... when writing the above code I started from a wrong example. Sorry. I meant this code:
 
Kelvin Okornoe
Ranch Hand
Posts: 130
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the suggestion so far, I have noted them.
Am still working on the program and I will be posting it here for more reviews.
Thank you.
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic