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
Olin [163]
3 years ago
15

The following procedure is intended to return the number of times the value val appears in the list nylist. The procedure does n

ot work as intended, Line 1: PROCEDURE countNumoccurences (mylist, val) Line 2: Line 3: FOR EACH item IN mylist Line 4: Line 5: count = 0 Line 6: IF(item = val) Line 7: tine 8: count count + 1 tine 9: Line 10: Eine 11: RETURN (count) Line 12:) Which of the following changes can be made so that the procedure will work as intended?
A. Changing line 6 to IF(item = count)
B. Changing line 6 to IF(myList[item) - val)
C. Moving the statement in line 5 so that it appears between lines 2 and 3
D. Moving the statement in line 11 so that it appears between lines 9 and 10 ->
Computers and Technology
2 answers:
Charra [1.4K]3 years ago
8 0

Answer:

option C is the answer....

allochka39001 [22]3 years ago
3 0

Answer:

C. Moving the statement in line 5 so that it appears between lines 2 and 3

Explanation:

Given

The attached procedure

Required

What should be modified

The problem in the procedure is on line 5

i.e. count = 0

This line is within the loop, and this means that the count variable is initialized to 0 each time the loop is repeated.

To solve this, the count variable has to be removed from the loop to somewhere before the loop.

<em>Hence, option (c) is correct</em>

You might be interested in
True or False. A network is a group of computers that can communicate.
Hunter-Best [27]
The answer is: false
3 0
3 years ago
. What part of the communication feedback loop results in unclear communication? A. Sender's message B. Interference C. Message
MakcuM [25]
D is ur final answer i hope i helped
7 0
3 years ago
Read 2 more answers
It is a good idea to include your teacher’s name on a title page.
kkurt [141]
I usually include my teachers name in the upper right hand corner along with the date my name and the subject.
6 0
4 years ago
Read 2 more answers
C++ <br> see attached file for quesion
sveticcg [70]
The picture doesn’t load.
7 0
3 years ago
Write a class named Car that has the following data attributes:
meriva

ANSWER

The program in JAVA for the given scenario is as follows.

import java.util.*;

public class Car

{

// variables declaration

   static int _year_model;

   static String _make;

   static int _speed;

   

   public static void _init_( int model, String m )

   {

// variables initialization

       _year_model = model;

       _make = m;

       _speed = 0;

   }

   

   public static void accelerate()

   {

       _speed = _speed + 5;

   }

   

   public static void brake()

   {

       _speed = _speed - 5;

   }

   

   public static int get_speed()

   {

// current value of speed is returned

       return _speed;

   }

   

public static void main(String[] args) {

     

    // object of class created

    Car ob = new Car();

     

    // method called using object of class

    ob._init_(2019, "audi");

     

    ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 ob.accelerate();

 System.out.println("Accelerated speed " + ob.get_speed());

 

 System.out.println();

 

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 ob.brake();

 System.out.println("Speed after brake " + ob.get_speed());

 

}

}

OUTPUT

Accelerated speed 5

Accelerated speed 10

Accelerated speed 15

Accelerated speed 20

Accelerated speed 25

Speed after brake 20

Speed after brake 15

Speed after brake 10

Speed after brake 5

Speed after brake 0

EXPLANATION

1. Variables are declared with String and integer datatypes.

2. _init_() initializes all the variables. This method is also called inside main() using object of Car class in order to initialize the variable speed to 0.

3. Inside main(), object of Car class created.

Car ob = new Car();

4. All the methods are called using object of the class.

ob._init_(2019, "audi");

ob.accelerate();

ob.brake();

5. All the variables are declared as static.

6. All the methods are declared as static since main() method is static inside which all other methods are called.

7. New line is included to improve readability of the output.

7 0
4 years ago
Other questions:
  • How can i put this sign in my keybord?<br><br> :::::<br> ^<br> Here is the sign
    8·1 answer
  • How do you mark somebody the brainliest?
    14·2 answers
  • In one to two sentences, describe one method for launching or opening a program.
    5·2 answers
  • Why is Brainly always deleting either my answers or my questions? I am putting nothing inappropriate in them. Can someone answer
    7·2 answers
  • Roman has painstakingly developed the animation for one of the objects on his slide. He can now use the Animation Painter to cop
    13·1 answer
  • You have a small network at home that is connected to the internet. On your home network, you have a server with the IP address
    14·1 answer
  • Write a Bash script that takes the name of a file or directory as an argument, 1. reports if it is a directory or a file, and if
    14·1 answer
  • Define<br>output<br>devices<br>.<br>Give<br>any<br>three<br>examples<br>.<br>3.​
    8·2 answers
  • LAB: Praising dates
    14·1 answer
  • The core of ___________ is the implementation of intrusion detection systems and intrusion prevention systems at entry points to
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!