Answer:
public class MagicSquare {
public static void main(String[] args) {
int[][] square = {
{ 8, 11, 14, 1},
{13, 2, 7,12},
{ 3, 16, 9, 6},
{10, 5, 4, 15}
};
System.out.printf("The square %s a magic square. %n",
(isMagicSquare(square) ? "is" : "is not"));
}
public static boolean isMagicSquare(int[][] square) {
if(square.length != square[0].length) {
return false;
}
int sum = 0;
for(int i = 0; i < square[0].length; ++i) {
sum += square[0][i];
}
int d1 = 0, d2 = 0;
for(int i = 0; i < square.length; ++i) {
int row_sum = 0;
int col_sum = 0;
for(int j = 0; j < square[0].length; ++j) {
if(i == j) {
d1 += square[i][j];
}
if(j == square.length-i-1) {
d2 += square[i][j];
}
row_sum += square[i][j];
col_sum += square[j][i];
}
if(row_sum != sum || col_sum != sum) {
return false;
}
}
return d1 == sum && d2 == sum;
}
}
Answer:
two types of storage devices used with computers a primary storage device such as r a m and the secondary storage device such as a hard drive secondary storage can be removable internet or external
Explanation:
hope it is helpful for you please make me brilliant only if you like this answers
Answer:
what is it that u need help with
Explanation:
Create an online portfolio - Depending on the type of work you desire, having your work visible will begin to make yourself known in the community.
Find yourself small work to do - Each and every piece of work you do benefit s yourself, as you learn and build greater skill in your field.
Search for opportunities across different platforms - Rather than waiting for an opportunity to come to you, go out and look for one.
Answer:
- def cubit2inch(c):
- inches = c * 18
- print(inches)
-
- cubit = int(input("Enter number of cubits: "))
- cubit2inch(cubit)
Explanation:
The solution code is written in Python 3.
Firstly, write a function cubit2inch that takes one input parameter, c. In the function, apply the formula to convert the cubit to inches and print it (Line 2 - 3).
In the main program, we prompt user to input number of cubits and convert it to numerical and assign it to cubit variable (Line 5). Call the function to print the converted inches (Line 6).