1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
finlep [7]
3 years ago
9

Question 1 of 10

Computers and Technology
1 answer:
mafiozo [28]3 years ago
6 0
D. A programming language
You might be interested in
(The Location class) Design a class named Location for locating a maximal value and its location in a two-dimensional array. The
-Dominant- [34]

Answer:

Here is the Location class:

public class Location {   //class name

   public int row;  // public data field to hold the value of no. of rows

   public int column;  // public data field to hold the value of no. of columns

   public double maxValue;   //public data field to hold the maximum value

   public Location(int row, int column, double maxValue) { //parameterized constructor of Location class

//this keyword is used to refer to a current instance variable and used to avoid naming conflicts between attributes and parameters with the same name

       this.row = row;  

       this.column = column;  

       this.maxValue = maxValue;     }  

   public static Location locateLargest(double[][] a) {   //method that takes a 2 dimensional array a as argument and returns the location of the largest element

       int row = 0;  //initializes row to 0

       int column = 0;  //initializes column to 0

       double maxValue = a[row][column];   //stores largest element

       for (int i = 0; i < a.length; i++) {  //iterates through rows of a[] array

           for (int j = 0; j < a[i].length; j++) {  //iterates through columns of array

               if (maxValue < a[i][j]) {  //if the maxValue is less than the element of 2 dimensional array at ith row and jth column

                   maxValue = a[i][j];  //then set that element to maxValue

                   row = i;  // i is set to traverse through rows

                   column = j;   }             }         }  // i is set to move through columns

       return new Location(row,column,maxValue);     }  } //calls constructor of class by passing row, column and maxValue as argument

Explanation:

Here is the Main class with a main() function to  test program  

import java.util.Scanner;   //to accept input from user

public class Main {   //class name

   public static void main(String[] args) {   //start of main function

       Scanner scan = new Scanner(System.in);  //creates Scanner class object to scan the input from user

 System.out.print("Enter the number of rows and columns in the array: ");  //prompt for user

       int row = scan.nextInt();  // reads value of row from user

       int column = scan.nextInt();  //reads input value of column

       double[][] array = new double[row][column];   //declares a 2 dimensional array named array

       System.out.println("Enter the array:");  //prompts to enter array elements

       for (int i = 0; i < array.length; i++) {  //iterates through the rows of array until the size of array is reaced

           for (int j = 0; j < array[i].length; j++) {  //iterates through the columns of array

               array[i][j] = scan.nextDouble();    }    }   //reads each element at i-th row and j-th column

       Location location = Location.locateLargest(array);  //calls locateLargest method by passing array to it in order to locate the largest element in the array

System.out.println("The largest element in a two-dimensional array is: " + location.maxValue);  //displays the largest element of array

       System.out.println("The location of the largest element is at (" + location.row + ", " + location.column + ")");       }    } //displays the location of the largest element in the two dimensional array

Suppose the user enters 2 rows and 2 columns. The elements are:

1         5.5

4.5      3

The program works as follows:

for (int i = 0; i < array.length; i++) this outer loop iterates through rows

i = 0

inner loop for (int j = 0; j < array[i].length; j++) iterates through columns

array[i][j] = scan.nextDouble(); reads the element at position i-th row and j-th column. This becomes:

array[0][0] = scan.nextDouble();

so element at 0th row and 0th column is 1

Location location = Location.locateLargest(array); now this calls the method which works as follows:

double maxValue = a[row][column]; this becomes:

double maxValue = a[0][0];

so maxValue = 1

for (int i = 0; i < a.length; i++) this loop in method iterates through rows and  for (int j = 0; j < a[i].length; j++) this iterates through columns of array

if (maxValue < a[i][j]) this becomes:

if (maxValue < a[0][0])

As we know that maxValue = 1 so this if condition is true.

                   maxValue = a[i][j];  this becomes:

             maxValue = a[0][0];  

maxValue = 1

Now set row = 0 and column = 0

Now the inner loop value of j is incremented to 1. So j = 1

At next iteration array[0][1] is checked. The element at this position is 5.5

if (maxValue < a[i][j]) is true because 1<5.5 so now value of maxValue becomes:

maxValue = 5.5

and

i = 0  j = 1

This way at each iteration of inner loop the columns are traversed and at each iteration of outer loop rows are traversed.

At next iteration element at array[1][0] is checked which is 4.5. This is not greater than maxValue so maxValue remains 5.5

At next iteration element at array[1][1] is checked which is 3. This is not greater than maxValue so maxValue remains 5.5 .

After both the loops end the statement:

return new Location(row,column,maxValue);

returns row , column and maxValue

where row = 0  column = 1 and maxValue = 5.5

So the output is:

The largest element in a two-dimensional array is: 5.5

The location of the largest element is at (0,1)

3 0
4 years ago
What is generalization error in terms of the SVM? a. How accurately the SVM can predict outcomes for unseen data b. How far the
andreev551 [17]

Answer:

a. How accurately the SVM can predict outcomes for unseen data

Explanation:

Generalization Error in terms of the SVM which is an acronym for Support Vector Machine, that deals with a form of administered learning standard, is a criterion of how accurately the Support Vector Machine algorithm can make a forecast of concluding information for formerly hidden data.

Hence, in this case, the correct answer is option A, which is Generalization error in terms of the SVM is "How accurately the SVM can predict outcomes for unseen data"

4 0
3 years ago
Java
Triss [41]

The program illustrates the use of catching exceptions using try and catch.

  • Exceptions are simply errors that can crash a program
  • Try and catch are used to prevent errors from crashing a program

The required try and catch block is as follows:

<em>try { </em>

<em>        System.out.print(names[index]); </em>

<em>    } </em>

<em>    catch (ArrayIndexOutOfBoundsException e) { </em>

<em>   System.out.println(e.getMessage()); </em>

<em>}</em>

The flow of the above code segment is as follows:

First, we begin with the try block

<em>try {</em>

Then the program prints the element at the index

<em>        System.out.print(names[index]);     }</em>

If the index does not exist in the array (e.g. -1 or 11), then the catch block is executed

<em>    catch (ArrayIndexOutOfBoundsException e) {</em>

This prints the appropriate exception

<em>   System.out.println(e.getMessage()); }</em>

See attachment for sample run

Read more about similar programs at:

brainly.com/question/21330187

7 0
3 years ago
What material replaced stone as the primary materials used to make tools and machines by humans
swat32

steel is pretty common, if not metal

4 0
4 years ago
How efficient would a 6-bit code be in asynchronous transmission if it had 1 parity bit, 1 start bit, and 2 stop bits?
Lana71 [14]
How efficient well if we are transmitting 6bits and we need 10 to transmit the 6 bits that would be 6/10 = .6 = 60% efficient.
7 0
3 years ago
Other questions:
  • What is the difference between a router and a modem
    15·1 answer
  • When creating a new user in linux, after entering the name, the username box:?
    9·1 answer
  • Enumeration is defined as the process of extracting user names, machine names, network resources, shares, and services from a sy
    13·1 answer
  • : How can Internet technologies help a business form strategic alliances with its customers, suppliers, and others?
    10·1 answer
  • What are the file sharing copyright laws in your area? Are they more strict or less strict than those in other areas of the worl
    9·1 answer
  • How do the steps taken by leaders of Athens reflect a turn towrd democracy
    10·1 answer
  • Which of these statements about symmetric key encryption is true? The file is encrypted with a private key and can be decrypted
    14·1 answer
  • Choose the answer. Janice's IT department found that her computer had a program on it that was collecting her personal informati
    5·1 answer
  • Among us Question. Worth 15 Points.<br> Which Vents do the Admin Vents Connect?
    14·2 answers
  • Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the smalle
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!