Giter VIP home page Giter VIP logo

matrix's Introduction

Matrix

Synopsis

This program allows the user to input a matrix in row-major order, and then the program prints the matrix to the screen in a neat and pretty format.

Enter the values of each row with commas in between each element. Enter one space between each row. Spaces at the very beginning or very end of user input will be ignored.

This program will keep asking for user input until the user inputs a matrix in the correct format. If you manage to break my program or it behaves in an unusual way, please tell me.

As a challenge, I did not use the split() function to separate the rows or to split the rows into their individual elements. So I had to use inner loops to achieve the same result. This lead to the program being longer that it could have been.

Please also note that the main reason why this program is so long is because of the extensive invalid-input-checking functions, which are used to tell the user specifically why the user input is invalid.

Example 1:

Enter Matrix: 1.11,2,33333.4 1,2,3 11.2,33.33,4

1.11 2.33333 4.0

1.00 2.00000 3.0

11.2 33.3300 4.0

Example 2: .1,.22,.3345 1,233.33,444 12.3,44.445,78.9

0.10 0.2200 0.3345

1.00 233.33 444.00

12.3 44.445 78.900

Rules:

  1. Do not enter more than one decimal point per number; numbers like ".2" or ".123" are allowed

  2. Two or more spaces may not be next to each other

  3. Two or more commas may not be next to each other

  4. A comma may not be next to a space

  5. All rows must be the same length

  6. Only Digits, decimal points, commas, and spaces are allowed in the user input

  7. The final character in the user input must be a digit

  8. The initial character in the user input must be a decimal point or a digit

Motivation

At first this was supposed to be a java program to write for fun, nothing too complicated. But then I decided to make it more challenging by making sure the user input was correct, not using the split() function, and printing the matrix in an easy-to-read manner.

Installation

Download the file main.java into an empty directory on your computer.

Commands:

$ javac main.java

$ java main

matrix's People

Contributors

aj96 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.