Free Program Array Programs In Bluej For Icse

First Java Program. Now that you have got the BlueJ installed it is time to write your first program.

Simple array programs in java
  • ICSE BlueJ Logical Program. All programs codes are Tested in BlueJ (The programs which are not solved try it out yourself, because one same pattern questions.
  • Regarding String programs, You have to think a String to be just like an array of characters. Like you use every element in the array by writing its index, similarly, in order to access the characters of a String, you need to extract the characters through their index using charAt() function.
  • 'Objects First with Java: A Practical Introduction Using BlueJ' is a textbook co-written by the developers of BlueJ and has sold hundreds of thousands of copies worldwide. Teacher support. Our free Blueroom website offers teaching resources and the chance to engage.
  • Bluej for ICSE A Complete reference to ICSE bluej. Searching in Java – Video Tutorial — May 30, 2017. Learn about Array Sorting in Java Programming! Generally, there are two types of Sorting in Java, they are, 1.Selection Sort. Program in Java to Accept a Sentence from the user, and store each word of the Sentence in an Array.
Active8 months ago
Array

For my class assignment we need to Write a class called Matrix that contains a private 2-dimensional int array called 'matrix' that can be up to 10 rows by 10 columns maximum. We need to use two constants MAXROWS=10 and MAXCOLS=10 to construct 'matrix.' The Matrix class will also need the following attributes:

The rows and cols will contains values that are less than equal to MAXROWS and MAXCOLS.Write a default Matrix class constructor that constructs the 'matrix' array with the following values:

The constructor must also set the rows and cols variables to match the above matrix.

Write a method 'getSumMatrix' that returns the sum of all the integers in the array 'matrix'.

Write a method 'getSumMatrixDiag' that returns the sum of all the integers in the major diagonal of the array 'matrix'. A major diagonal is the diagonal formed from the top left corner to the bottom right corner ofthe matrix.

Would it be possible to have my code looked over(where i initialize the array and fill it with values to ensure it is correct. The part I am stuck on is the getSumMatrix and getSumMatrixDiag. The getSumMatrix method errors out on the line 'for(i=0; i < a.matrix; i++)' and tells me ' cannot find symbol - variable matrix'. WOuld the getSumMatrixDiag be the same way.Why is that? Thank you so much.

Here is my code

/**Sophia Ali

  1. Matrix, getSumMatrix, getSumMatrixDiag:

    Email just Matrix.java.

    Write a class called Matrix that contains a private 2-dimensional intarray called 'matrix' that can be up to 10 rows by 10 columns maximum.Use two constants MAXROWS=10 and MAXCOLS=10 to construct 'matrix.'

    The Matrix class will also need the following attributes:

    private int rows; // number of rows to use in matrix private int cols; // number of cols to use in matrix

    The rows and cols will contains values that are less than equal toMAXROWS and MAXCOLS.

    Write a default Matrix class constructor that constructs the 'matrix'array with the following values:

    {{1,2,4,5},{6,7,8,9},{10,11,12,13}, {14,15,16,17}}

    The constructor must also set the rows and cols variables to match theabove matrix.

    Write a method 'getSumMatrix' that returns the sum of all the integersin the array 'matrix'.

    Write a method 'getSumMatrixDiag' that returns the sum of all theintegers in the major diagonal of the array 'matrix'. A major diagonal isthe diagonal formed from the top left corner to the bottom right corner ofthe matrix.

    You do not have to write a TestMatrix class to test the Matrix class.Just use the BlueJ object creation and testing feature.

    */public class Matrix{

    }

EDIT:

I am using BlueJ to run my program and when I run it I get the error 'Error incompatible types'. I am not sure if my coding is wrong (when I compile it, it compiles with no syntax errors) or if I am using BlueJ incorrectly.

Sophia Ali
Sophia AliSophia Ali
882 gold badges4 silver badges14 bronze badges

2 Answers

In your code scope of matrix variable is just inside the constructor. So it is not visible in getSumMethod. Also a is an array as specified above a.matrix is not correct.

Array Programs In C#

Please try following. Call method getSumMethod(matrix) passing matrix as an argument and replace a.matrix with a. Then see you can move forward at least something (may be another error). If you try below then you will error related to data types which you can resolve by putting correct logic. But this code needs lot of improvement to behave the way you need it.

Simple Array Programs In Java

Harish KumarHarish Kumar

Sorry to all, I don't know this is the one you wana now, but this will helps you.

Free Program Array Programs In Bluej For Icse 2017

...

Ramesh JRamesh J
4412 gold badges9 silver badges24 bronze badges

Not the answer you're looking for? Browse other questions tagged javaconstructormultidimensional-arraybluej or ask your own question.