Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search

Write a program that calculates and prints the product of FIVE integers.

Can you change the code into java code?




def reflexive(R):



'''



@param R : set containing homogenous elements



'''



result = []



a = []



y = []




for a1, a2 in R:



if (a1 == a2):



result.append((a1,a2))



y.append(a1)




if (a1 not in a):



a.append(a1) #contains list of a0




if (set(a) == set(y)):



print("Reflexive")



return (result, True)




print("Not Reflexive")



return ([] , False)

How to determine the set is transitive using java code?

How to fix this error?



void reflexive(int a[], int sizeOfA, int b[], int sizeOfB){


int i, j;


bool test;


bool hold = true;




for(i = 0; i < sizeOfA; i++)


{


if(hold == true)


{


for(j = 0; j < sizeOfB;)


{


if(b[j]==a[i] && b[j+1]==a[i])


{


hold = true;


break;


}


else


{


hold = false;


j++;


}


}


}


}


if(hold == true)


{


test = true;


cout << "Reflextive - Yes" << endl;


}


else


{


test = false;


cout << "Reflextive - No" << endl;


}


}

Write a program to calculate students' average test scores and their grades. You may assume the following input data:

Johnson          85       83       77       91       76

 Aniston           80       90       95       93       48

Cooper                78          81          11          90          73

Gupta                  92          83          96          38          59

Blair                      23          45          96          38          59

Clark                     60          85          45          39          67

Kennedy             77          31          52          74          83

Bronson              93          94          89          77          97

Sunny                  79          85          28          93          82

Smith                   85          72          49          75          63

 

Use four arrays: a one-dimensional array to store the students' names, a (parallel) two-dimensional array to store the


Cafeteria system is an important part of any institute. The university wants to automate the


cafeteria system you can help by identifying different classes along with their relationships.


University café has different customers (Employees, Students) that visit it for buying different


kinds of food. We want to make the system online so when a customer wants something he should


order it through a server. Whenever a customer comes to café he/she orders the food from specific


category. When a user wants to order something menu is displayed showing different food corners


(FastFood, ProperMeal, Beverages). After the order is placed generate bill for the user according


to the order he has placed. Identify the classes their relationship and function prototype of each


class

In a super market Mr. Amir has purchased 3 quantities of the same item. The bill is computed using the below formula Bill = quantity * price per item Requirements: a) The quantity and price per item has to be captured b) The bill has to be computed using the above formula c) Bill has to displayed


Write a method called isIdentityMatrix which will take a two-dimensional integer

array as argument, and returns true if the array is an identity matrix, or false otherwise.

You may use the following header for this method:

static boolean isIdentityMatrix(int[][] array)

A matrix is an identity matrix if it is a square matrix, and all its elements at the left

diagonal are ones, and all other elements are zeroes.

For example, the following matrix is an identity matrix and the method should return true

if we pass it to the isIdentityMatrix matrix as two-dimensional:

1 0 0 0 0

0 1 0 0 0

0 0 1 0 0

0 0 0 1 0

0 0 0 0 1

For the following two-dimensional array, the method should return false because there

are some non-zero elements in the matrix.

1 0 0 5 0

0 1 0 2 0

0 3 1 0 0

0 0 0 1 5

0 5 0 0 1

Similarly, for the following two-dimensional array, the method should return false

because some elements at left diagonal are not ones.

1 0 0 0 0

0 0 0 0 0

0 0 0 0 0

0 0 0 1 0

0 0 0 0 1


Write a method called addMatrices which will take two matrices (two-dimensional

integer arrays) as argument, and returns the addition of these two matrices as a two-

dimensional integer array.

You may use the following header for this method:

static int[][] addMatrices(int[][] firstMatrix,

int[][] secondMatrix)

For example, if we pass the following two two-dimensional arrays to the method:

5 7 9 4 3 7 3 2 1 5

2 3 9 7 6 3 9 4 0 3

3 6 8 7 9 6 2 8 9 4

1 9 7 5 6 5 0 3 8 7

3 8 7 9 2 1 6 8 4 3

Then the method should return the following two-dimensional array:

12 10 11 5 8

5 12 13 7 9

9 8 16 16 13

6 9 10 13 13

4 14 15 13 5


2. Write a method called printArray that takes a two-dimensional integer array as

argument and prints all elements of array. The method should print each row line by line.

You may use the following header for this method:

static void printArray(int[][] array)

In the main method:

 Declare and initialize two two-dimensional arrays.

 Pass these two-dimensional arrays to addMatrices()method..


In this task, you are being asked to write methods that manipulate arrays in Java.

1. Write a method called swapFirstAndLastRow which will take a two-dimensional

integer array as argument and swap all the values of first row and last row with each

other.

You may use the following header for this method:

static void swapFirstAndLastRow(int[][] array)

For example, if we pass the following two-dimensional array to this method:

5 7 9 4 3 1

2 4 9 7 6 5

3 6 8 7 9 4

1 9 7 5 6 3

Then the array will become:

1 9 7 5 6 3

2 4 9 7 6 5

3 6 8 7 9 4

5 7 9 4 3 1


2. Write a third method called printArray which will take a two-dimensional integer

array as argument and prints all elements of array. The method should print each row line

by line.

You may use the following header for this method:

static void printArray (int[][] array)


Take two numbers from the user as the size of rows and columns of the array and call the

methods in the following order:

 printArray()

 swapFirstAndLastRow()

 printArray


LATEST TUTORIALS
APPROVED BY CLIENTS