No I dont know how to catch the error. I just want to create a while loop that prints a message saying Error invalid entry until they input a valid integer.
Example:
How many disks should we...
Type: Posts; User: Bayonetwork
No I dont know how to catch the error. I just want to create a while loop that prints a message saying Error invalid entry until they input a valid integer.
Example:
How many disks should we...
Yes I deleted that line and if I input 0 it does nothing and if I input a character it throws an exception on my int userinput = keyboard.nextInt(); for an input mismatch. Obviously because I enter a...
Again, I just wrote that as a placeholder. "int" in the line if (user input == int) is a syntax error and will not compile. That is just what I want it to do but dont know how to code for it. In...
It just gives me an invalid expression error for the if (userinput == int) line. I just wrote that as a placeholder until I know to do for "int."
I do have another error checking question in the following code between the error checking start and end segment:
import java.util.Scanner;
public class Recursion {
public static void...
Solved:
public void display() {
for (int i = 0; i < rows(); i++){
for (int j = 0; j < columns(); j++){
System.out.print(matrix[i][j] + " ");
}...
This sounds like what I want to do. How do I determine when the last element is printed?
My code is properly formatted it just didnt preserve it when I copy/pasted to this forum from Eclipse. All the brackets and statements are where they should be.
Thanks!
I need it to have the format:
1 2 3
4 5 6
with tab spacing.
And allow for any size matrix the user might input. This is just a simple 2 x 3 example.
I need to be able to display to the console the rows and columns of the matrix.
Heres the matrix I want to display in the same format:
import java.util.Scanner;
public class MatrixMain {
...
Im getting an exception in my display method.
I need to be able to display to the console the rows and columns of the matrix.
Heres the matrix I want to display:
import java.util.Scanner;
...