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
MrRissso [65]
3 years ago
8

Problem: you need to write a code that read 2 array of size 10x10 of zero and ones that represent black

Computers and Technology
1 answer:
castortr0y [4]3 years ago
3 0

Answer:

import java.util.Scanner;

import java.lang.*;

public class Main

{

       //variables declared static; to be used inside main()

       static int err;

    static int size=10;

    //arrays declared static; to be used inside main()

       static int[][] white = new int[size][size];

       static int[][] black = new int[size][size];        

   //method to recognize any errors in the image    

   static int recognition(int[][] img)

   {

       //variable to indicate any error

       int notImage=0;

       if(img[1][1]==0)

       {

           for(int l=0;l<size; l++)

           {

               for(int k=0;k<size; k++)

               {

                   if(img[l][k]!=0)

                       notImage++;

               }

           }

       }

       else

       {

           for(int l=0;l<size; l++)

           {

               for(int k=0;k<size; k++)

               {

                   if(img[l][k]!=1)

                       notImage++;

               }

           }

       }

       if(notImage!=0)

           return -1;

       else    

           return 0;

   }

public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

 System.out.println("Enter the elements for 2d black array of size 10(enter 0): ");

 for(int l=0;l<size; l++)

       {

           for(int k=0; k<size; k++)

           {

               white[l][k]=sc.nextInt();    

           }

       }

 System.out.println("Enter the elements for 2d white array of size 10(enter 1): ");

 for(int l=0;l<size; l++)

       {

           for(int k=0; k<size; k++)

           {

               black[l][k]=sc.nextInt();    

           }

       }

 err = recognition(white);

 if(err==-1)

     System.out.println("White image has errors.");

 else    

     System.out.println("White image does not has errors.");

 

    err = recognition(black);

 if(err==-1)

     System.out.println("Black image has errors.");

 else    

     System.out.println("Black image does not has errors.");

}

}

OUTPUT

Program tested for smaller sizes.

Explanation:

1. Two two dimensional integer arrays are declared.

2. The variable size is declared and initialized to 10.

3. The main() prompts the user to enter the elements for both arrays; 1 for white and 0 for black.

4. Both the arrays are initialized inside two for loops independently.

5. These arrays are passed as parameter to the method, recognition(), one at a time.

6. Inside recognition(), an integer variable, notImage is declared and initialized to 0. If any other integer, other than 0 or 1 is encountered in the respective arrays, this variable is initialized to -1.

7. Inside main(), an integer variable, err, is declared. This variable stores the value returned by recognition().

8. Depending on the value of variable, err, message is displayed to the user appropriately.

You might be interested in
Help need urgently answer ​
skad [1K]

Answer:

Explanation:

b

6 0
3 years ago
Read 2 more answers
To find the area, Andrea tiled a rectangle and sketched her answer. Sketch Andrea's rectangle, and find the area. Show your mult
seraphim [82]

Answer:

Area = 6.25

Explanation:

Given

Length = 2.5

Width = 2.5

See attachment for rectangle

Required

Determine the area of the rectangle

Area is calculated as:

Area = Length * Width

This gives:

Area = 2.5 * 2.5

Area = 6.25

<em>The area of Andrea's sketch is 6.25</em>

8 0
3 years ago
Write a function addOddMinusEven that takes two integers indicating the starting point and the end point. Then calculate the sum
snow_lady [41]

Answer:g

   public static int addOddMinusEven(int start, int end){

       int odd =0;

       int even = 0;

       for(int i =start; i<end; i++){

           if(i%2==0){

               even = even+i;

           }

           else{

               odd = odd+i;

           }

       }

       return odd-even;

   }

}

Explanation:

Using Java programming language:

  • The method addOddMinusEven() is created to accept two parameters of ints start and end
  • Using a for loop statement we iterate from start to end but not including end
  • Using a modulos operator we check for even and odds
  • The method then returns odd-even
  • See below a complete method with a call to the method addOddMinusEven()

public class num13 {

   public static void main(String[] args) {

       int start = 2;

       int stop = 10;

       System.out.println(addOddMinusEven(start,stop));

   }

   public static int addOddMinusEven(int start, int end){

       int odd =0;

       int even = 0;

       for(int i =start; i<end; i++){

           if(i%2==0){

               even = even+i;

           }

           else{

               odd = odd+i;

           }

       }

       return odd-even;

   }

}

8 0
3 years ago
A computer lab has two printers. Printer I handles 40% of all the jobs. Its printing time is Exponential with the mean of 2 minu
Dennis_Churaev [7]

Answer:  0.3042

Explanation:

Let A  and B are the events to that job done by Printer I and Printer II respectively.

Given : P(A)=0.40    P(B)=0.60

Printing time of Printer I is Exponential with the mean of 2 minutes.

i.e. average number of job done in one minute:\lambda=\dfrac{1}{2}

The cumulative distribution function (CDF) for exponential distribution:-

F(x)=1-e^{-\lambda x}, where \lambda is the mean.

Then, the cumulative distribution function (CDF) for Printer I:-

P(X|A)=1-e^{-\dfrac{1}{2} x}

i.e. P(X

Printing time of Printer II is Uniform between 0 minutes and 5 minutes.

The cumulative distribution function  (CDF) for uniform distribution in interval (a,b) :-

F(x)=\dfrac{x-a}{b-a}

Then, P(X|B)=\dfrac{x-0}{5-0}=\dfrac{x}{5}

i.e. P(X

Now, the required probability :-

\text{P(A}|X

Hence, the required probability = 0.3042

3 0
4 years ago
What is the vibrating or buzzing of a hand controller known as?.
sergejj [24]

It should be noted that the vibrating or buzzing of a hand controller known as Controller vibration.

<h3>What is Controller vibration use for ?</h3>

The vibration controller helps to provide tactile feedback to the user. It is used to interacts with a power amplifier, shaker to implement a vibration test.

Learn more about Controller vibration at:

brainly.com/question/14078371

6 0
3 years ago
Read 2 more answers
Other questions:
  • Given the following stream of accesses to a 4-block fully associative cache with LRU replacement, determine whether the access i
    8·1 answer
  • The ________ defines every object and element on a web page.
    13·1 answer
  • Assume that isIsosceles is a bool variable, and that the variables isoCount, triangleCount, and polygonCount have all been decla
    7·1 answer
  • What does a compiler do, and why is it necessary when using higher-level languages?
    10·1 answer
  • What is the first thing you should do when creating a spreadsheet
    5·1 answer
  • A teacher determines student percentages in a course as the points a student earns divided by the total points available in the
    9·1 answer
  • Your program will search for prime numbers. You will first ask the user for the range of values to search, and use for loops to
    6·1 answer
  • What Temperature does mainframe need
    15·2 answers
  • Is climate change a man-made problem or a natural occurrence ? Why or why not ?
    8·1 answer
  • Write a program that generates 100 random numbers and keeps a count of how many of those random numbers are even and how many of
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!