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
77julia77 [94]
3 years ago
8

In the following code fragment, how many times is the count() method called as a function of the variable n? Use big-O notation,

and explain briefly. for (int i = 0; i < 3; i++) { for (int j = 0; j < n; j++) { for (int k = 0; k < j; k++) { count(); } }
Computers and Technology
1 answer:
ahrayia [7]3 years ago
4 0

Answer:

The loop counts the count() function length of n-1 times with respect to n.

Explanation:

The first and outer loop counts for two times as the variable declared in the condition counts before the iteration is made. The same goes for the other for statements in the source code.

The n represents the number length of a range of numbers or iterables (like an array).

You might be interested in
If I gain a rank and go under the points that the rank coust do I lose the rank
padilas [110]
This is a good question, and I've wondered about that myself. I'm going to 'report' the question, not because there's anything wrong with it, but to bring it to the attention of the Moderators, so they can tell both of us.
4 0
3 years ago
Read 2 more answers
Create a brief program that demonstrates use of a Java exception. For example, you could use InputMismatchException and ask the
HACTEHA [7]

Answer:

Here is the program that demonstrates the use of JAVA exception:

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

public class Main {  //class name

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

      Scanner input = new java.util.Scanner(System.in);  //creates Scanner class object to accept input from user

       int number1 = 0;  //stores the first integer value

       int number2 = 0;  //stores the second integer value

       while(true) {  //keeps looping until user enters integer value

           System.out.println("Enter 2 integers to perform addition: "); //prompts user to enter two integer values

           try {  //defines a chunk of code to check for errors        

               number1 = input.nextInt(); //reads input integer 1

               number2 = input.nextInt(); //reads input integer 2                  

               break;             }  

           catch (java.util.InputMismatchException e) { // defines a code chunk to execute if an error occurs in the try code chunk

              System.out.println("Input must be an integer "); //displays this message if user enters anything other than an integer value

              input.nextLine();              }         }  // reads input from user again until user enters both integer type values

       System.out.println("The sum is: " + (number1+number2));      }  } //if user enters 2 integers then computes and displays the sum of two integer values

Explanation:

The program uses InputMismatchException exception and asks the user to input two integers and computes the sum of two integers if user enters  integers otherwise an exception InputMismatchException is thrown and a error message Input must be an integer is displayed to the user if they input a string of letters instead o f integer values. Here while loop is used which keeps executing until user enters both the integer values. After the user enters correct values, the sum of the two integers are computed and result is displayed on output screen. The screenshot of program and its output is attached.

Another program asks the user to input an integer and the program executes correctly if they enter an integer but exception InputMismatchException is thrown with an error message that is is displayed to the user if they input a string of letters. Here is the program:

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       Scanner input = new java.util.Scanner(System.in);

       int number1 = 0;          

       while(true) {

           System.out.println("Enter an integer value: ");        

           try {

               number1 = input.nextInt();  

               break;             }  

           catch (java.util.InputMismatchException e) {

              System.out.println("Input must be an integer ");

              input.nextLine();             }        }  

       System.out.println("The program executed correctly!");  } }

7 0
3 years ago
___refers to self-acting or self-operating.
lisabon 2012 [21]

Answer:

do it to me watch this

Explanation:

trailing zeros in a whole number with no decimal shown are NOT significan

6 0
4 years ago
Within a classful addressing subnet mask, the ____ bits indicate that corresponding bits in an IPv4 address contain network info
Minchanka [31]

Within a classful addressing subnet mask, the 32 bits indicate that corresponding bits in an IPv4 address contain network information.

<h3>What is classful IP addressing?</h3>

IP address is the address or the code of location to reach at a specific location. It is a unique address of 32 bit.

This address is classified in five classes.

  • Class A
  • Class B
  • Class C
  • Class D
  • Class E

These class are necessary to obtained the bits for network ID.

Thus, within a classful addressing subnet mask, the 32 bits indicate that corresponding bits in an IPv4 address contain network information.

Learn more about the classful IP addressing here:

brainly.com/question/16842000

#SPJ1

5 0
2 years ago
You have a motion security light by your door. A cat run across it and the light turns on. What is the input of this system and
pishuonlain [190]
Input is that the security system relies on unauthorized motion of something coming accross for it to alert you. output is that once something is sense the light turns on.. the cat is a 1 and no cat is a 0 like 0 and 1s
5 0
3 years ago
Other questions:
  • Consider the following general code for allowing access to a resource:
    13·1 answer
  • Which activity constitutes legal computer activity?
    12·1 answer
  • Consider the recursive method whose definition appear below. Why? public static String mysteryString (String s){ if(s.length()==
    10·1 answer
  • What is social media ​
    13·2 answers
  • Python Coding:
    15·1 answer
  • Which lines of the code, marked by Q, are legally declared based on the scope of the variable?​
    6·1 answer
  • In a relational database, information is organized into tables in which each row represents a(n ) ________. Group of answer choi
    6·1 answer
  • Ninety percent of the fastest-growing jobs require some kind of postsecondary education.
    7·1 answer
  • in a small town, there are two providers of broadband internet access: a cable company and the phone company. the internet acces
    5·1 answer
  • What is 4365 −3412 when these values represent
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!