The following procedure is intended to return the number of times the value val appears in the list nylist. The procedure does not 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 ->
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.
Hence, option (c) is correct
Throughout our procedure, even though we proclaimed count = 0 inside the for loop, the count has been valued at 0.
After that, When a certain value is found equal to Val, the count has been incremented by 1. The count is set to 0 again in the next iteration, so at the end, if we found an element equivalent to Val 1, its real count has been returned.To get around this, we'll define count outside of the for loop to acquire the true count of instances of that specific value.Therefore, the answer is "Option C".
Learn more:
brainly.com/question/14941418
A suggestion for improving the user experience
for the app navigation, has the following
severity
Usability
Low
Critical
Medium
High
User experience is one of the most important things considered in the modern IT world. Almost 90% of the population is dependent on mobile phones, electronic devices. So, one things that come is app development. Therefore, in order to enhance more growth in app development, there need to better user experience. We need to think about users and i don't Know More info.
Use at Least one hundred words to explain what you did the last time your handheld personal computer went slow.
Answer:
Disk defragmentation
clear up storage
restart the computer
Explanation:
PC's going slow is a very common occurence nowadays and what i had to do to usually fix slow computers is to first use disk defragmentation which will automatically sort our files and put them in the right order.Second is to delete any unnessary files,folders,programs that i no longer use or its just sitting there eating dust and finally my last resort is to restart the pc which usually helps fix most of the issues including slow PCs which might be caused by some errors during startup.
Hope this helped
NEED HELP IMMEDIATELY!!
What is the difference between a worm and a typical virus?
A) Worms are a type of spyware; viruses are a type of malware.
B) Worms are impossible to remove; viruses can be tracked and removed.
C) Worms are stronger than viruses; viruses are stronger than spam.
D) Worms travel independently of human action; viruses require human actions.
Answer:
Option C
Explanation:
Option A is incorrect as Worm is a form of malware
Option B is incorrect because antivirus can remove all forms of malware
Option C is correct because a worm is more problematic as compared to the virus. Also, viruses are weaker than worm because they need a host file to run but a worm can work independently.
Option D is also incorrect because both are able to self replicate.
Color, font, and images are all important aspects of good
I'll mark brainest
Answer:
of good design, so its c ....
Answer: Design
Color, font, and images are all important aspects of good Design.
, Hope this helps :)
Have a great day!!
HTML tag that makes a text field used by javascript statement
Complete the sentence.
In your program, you can open
In your program, you can open a file using the open() function in Python.
What is the program about?A high-level, all-purpose programming language is Python. Code readability is prioritized in its design philosophy, which makes heavy use of indentation. Python uses garbage collection and has dynamic typing.
It supports a variety of programming paradigms, such as functional, object-oriented, and structured programming. The open() function in Python allows you to open a file, read its contents, and perform various operations on it, such as writing, appending, etc.
Learn more about program on:
https://brainly.com/question/26642771
#SPJ1
1.Write a Java program to solve the following problem using modularity. Write a method that rotates a one-dimensional array with one position to the right in such a way that the last element becomes the first element. Your program will invoke methods to initialize the array (random values between 1 and 15) print the array before the rotation, rotate the array, and then print the array after rotation. Use dynamic arrays and ask the user for the array size. Write your program so that it will generate output similar to the sample output below:
Answer:
Explanation:
The following code is written in Java and it asks the user for the size of the array. Then it randomly populates the array and prints it. Next, it rotates all the elements to the right by 1 and prints the new rotated array.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;
class Brainly {
public static void main(String[] args) {
Random r = new Random();
Scanner in = new Scanner(System.in);
System.out.println("Enter Size of the Array: ");
int arraySize = in.nextInt();
ArrayList<Integer> myList = new ArrayList<>();
for (int x = 0; x < arraySize; x++) {
myList.add(r.nextInt(15));
}
System.out.println("List Before Rotation : " + Arrays.toString(myList.toArray()));
for (int i = 0; i < 1; i++) {
int temp = myList.get(myList.size()-1);
for (int j = myList.size()-1; j > 0; j--) {
myList.set(j, myList.get(j - 1));
}
myList.set(0, temp);
}
System.out.println("List After Rotation : " + Arrays.toString(myList.toArray()));
}
}
Programming errors can result in a number of different conditions. Choose all that apply.
The program will halt execution.
An error message will be displayed.
Incorrect results will occur.
Code will run faster.
the first 3
Answer:
The program will halt execution and and error message will be displayed. Probably number 3 too.
Answer:
A, B and C
Explanation:
Requirements description:
Assume you work part-time at a Cafe. As the only employee who knows java programming, you help to write an ordering application for the store.
The following is a brief requirement description with some sample output.
1. Selecting Breakfast or Lunch(5 points)
When the program starts, it first shows option Breakfast or Lunch. A sample output is as follows.
=== Select Breakfast or Lunch: ===
1. Breakfast
2. Lunch
You are supposed to validate the input.
If the user enters a letter or a number not between 1 and 2, the user will see an error message.
A sample output for invalid number is as follows.
Select Breakfast or Lunch [1, 2]: 0
Error! Number must be greater than 0.
Select Breakfast or Lunch [1, 2]:
2. Selecting Coffee (20 points)
When the program continues, it shows a list/menu of coffee and their prices, then asks a user to select a coffee by entering an integer number. A sample output is as follows.
=== Select Coffee: ===
1 Espresso $3.50
2 Latte $3.50
3 Cappuccino $5.00
4 Cold Brew $3.00
5 Quit Coffee selection
Select a coffee [1, 5]:
You are supposed to validate the input.
If the user enters a letter or a number not between 1 and 5, the user will see an error message.
A sample output for invalid number is as follows.
Select a coffee [1, 5]: 0
Error! Number must be greater than 0.
Select a coffee [1, 5]:
In your program, you can hard-code the information for coffee (i.e., coffee names and prices) shown above, such as "1 Espresso $3.50" and use the hard-code price, such as 3.50, for calculation of a total price of the order.
After the user makes a choice for coffe, such as 2 for Latte. The program continues asking for selecting a coffee so that the user can have multiple coffee orders. The user can enter "5" to quit coffee selection. A sample output is as follows.
=== Select Coffee: ===
1 Espresso $3.50
2 Latte $3.50
3 Cappuccino $5.00
4 Cold Brew $3.00
5 Quit Coffee selection
Select Coffee: [1, 5]: 2
=== Select Coffee: ===
1 Espresso $3.50
2 Latte $3.50
3 Cappuccino $5.00
4 Cold Brew $3.00
5 Quit Coffee selection
Select Coffee: [1, 5]: 5
3. Selecting Food (10 points)
After Coffee selection, the program shows food selection. A sample output is as follows.
=== Select Food: ===
1 Tuna Sandwich $10.00
2 Chicken Sandwich $10.00
3 Burrito $12.00
4 Yogurt Bowl $8.00
5 Avocado Toast $8.00
6 Quit Food selection
Select Food: [1, 6]: 1
Input validation is needed and works as before. Like Coffee selection which allows selecting multiple Coffee orders, food selection also repeats after the user enters a valid number between 1 and 5.
You hard-code the information for food shown above, such as "1 Tuna Sandwich $10.00" and use the hard-code price, such as 10.00, for calculation of the total price of the order.
Answer:
The code has been written in Java.
The source code of the file has been attached to this response. The source code contains comments explaining important lines of the program.
A sample output got from a run of the application has also been attached.
To interact with the program, kindly copy the code into your Java IDE and save as Cafe.java and then run the program.