COMP-SCI 7202 Practical-03: Arrays and Methods – Part I solution

$40.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (2 votes)

Problem 01: Arrays & For Loops

In this problem, you are asked to create methods in the class BaseOperations.

Problem 02 – Prime Number

In this problem, you are required to ask for user input of a number. Your program should check whether the number is prime or not.

1 https://version-control.adelaide.edu.au/svn/axxxxxxx/2019/s2/fcs/week-03/practical-03
printArray
You are asked to create a function that performs the printing of a given array;
Signatures:
void printArray(int [] array);
void printArray(String [] array);
void printArray(Float [] array);

Reversing an array
You are asked to create a function that changes the order of the elements of a given array in reverse order;
Signature
int [] reverseArray(int [] array)
String [] reverseArray(String [] array)
float [] reverseArray(float [] array)

Test Case:
array = {1,2,3,4}
printArray(array)
[1,2,3,4]
array = reverseArray(array)
printArray(array)
[4,3,2,1]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

Problem 03 – Comparison

In this problem, you are required to ask two number for your user. Write a Program to read the number and to display the largest value between:

Problem 04 – Mathematical Operations

A complex number is a number that can be expressed in the form a + bi, where a and b are real numbers, and i is a solution of the equation x2 = −1.

Because no real number satisfies this
equation, i is called an imaginary number. For the complex number a + bi, a is called the real part, and b is called the imaginary part. Despite the historical nomenclature “imaginary”, complex
numbers are regarded in the mathematical sciences as just as “real” as the real numbers and are fundamental in many aspects of the scientific description of the natural world.

Write a Program
to perform the following arithmetic operations of a complex number using a structure.
Test case:
———-
Please, insert a number: 2
Your number is prime
———-
———-
Please, insert a number: 10
Your number is not prime
———-

Requirements:
* Handle exceptions;
* Handle wrong inputs, such as Strings;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

Test case:
———-
Please, insert a number (1): 2
Please, insert a number (1): 3
The bigger number is 3;
———-
———-
Please, insert a number: 10
Please, insert a number: -55
The bigger number is 10
———-

Requirements:
* Handle exceptions;
* Handle wrong inputs, such as Strings;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20

Signature
class name: ComplexCalculator
1
2
3

Problem 05 – Matrix Determinant

Background: In linear algebra, the determinant is a scalar value that can be computed from the elements of a square matrix and encodes certain properties of the linear transformation described
by the matrix. The determinant of a matrix A is denoted det(A), det A, or |A|.

Geometrically, it can be viewed as the volume scaling factor of the linear transformation described by the matrix.

This is also the signed volume of the n-dimensional parallelepiped spanned by the column or row vectors of the matrix. The determinant is positive or negative according to whether the linear
mapping preserves or reverses the orientation of n-space. (This background is not assessable but useful to know in computer science.)

or
In this problem, you are asked to define a multi-dimensional array and perform a matrix determinant operation. Note that due to the complexity of this operation you are required to develop only
matrices 2×2 and 3×3. To calculate a determinant you can use the following steps. But you can use any correct method you choose.

Set the matrix (must be square).

Reduce this matrix to row echelon form using elementary row operations so that all the elements below diagonal are zero.

Multiply the main diagonal elements of the matrix – determinant is calculated.
Here is an example of how your program should behave:

Requirements:
(a). Addition of the two complex numbers (add)
(b). Subtraction of the two complex numbers (sub)
(c). Multiplication of the two complex numbers (multiplication)
(d). Division of the two complex numbers. (division)
4
5
6
7
8
9
10
11
12
13

Welcome to Matrix Determinant Calculator!
Would you like to calculate the determinant of a new matrix?
1. Yes, 2. No
Option: 1
1
2
3
4
5
Total points: 100.0
Basic Marking Scheme
Criteria Ratings Pts
20.0 pts
40.0 pts
10.0 pts
30.0 pts
Good luck!

What is the dimension of the matrix?
Input: 3×3
1
2

Great! Let’s calculate this determinant then.
Please insert all the values for your matrix.
New matrix [1][1]: 12
New matrix [1][2]: 151
New matrix [1][3]: 12

New matrix [3][1]: 1
New matrix [3][2]: 22
New matrix [3][3]: 22
1
2
3
4
5
6
7
8
9
10
11
12

The determinant of your matrix is:
| 12, 151, 12 |
| 1, 1, 1 |
| 1, 22, 22 |
Determinant: -2919
1
2
3
4
5
6
7
Compilation

In order to achieve full marks – your code must compile and run;

Basic Functionality
Your code (1) perform all the functions correctly, (2) use latest concepts learned in class, (3) has a clear, creative and sophisticated way of solving the problem.

Functionality Extension
Your code (1) perform all the functions correctly, (2) use latest concepts learned in class, (3) has a clear, creative and sophisticated way of solving the problem, and (4) you propose novel ways to
solve the problems – or extra functionalities.

Code Formatting
Your code (1) has the right proportion of comments and place line and block comments correctly, (2) follow correct indentation every new indentation level, (3) has good variable naming, (4) has
clear organization between tabs and is easy to read.