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
Evgesh-ka [11]
4 years ago
7

Write a program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of

students having scores in each of the following ranges:
0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200.
Output the score ranges and the number of students. (Run your program with the following input data:
76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189.)
Computers and Technology
1 answer:
BartSMP [9]4 years ago
6 0

Answer:

The solution code is written in Python:

  1. with open("text1.txt") as file:
  2.    data = file.read()
  3.    numbers = data.split(",")
  4.    group_0_24 = 0
  5.    group_25_49 = 0
  6.    group_50_74 = 0
  7.    group_75_99 = 0
  8.    group_100_124 = 0
  9.    group_125_149 = 0
  10.    group_150_174 = 0
  11.    group_175_200 = 0
  12.    for x in numbers:
  13.        if int(x) > 174:
  14.            group_175_200 = group_175_200 + 1
  15.        elif int(x) > 149:
  16.            group_150_174 = group_150_174 + 1
  17.        elif int(x) > 124:
  18.            group_125_149 = group_125_149 + 1
  19.        elif int(x) > 99:
  20.            group_100_124 = group_100_124 + 1  
  21.        elif int(x) > 74:
  22.            group_75_99 = group_75_99 + 1  
  23.        elif int(x) > 49:
  24.            group_50_74 = group_50_74 + 1
  25.        
  26.        elif int(x) > 24:
  27.            group_25_49 = group_25_49 + 1
  28.        
  29.        else:
  30.            group_0_24 = group_0_24 + 1
  31. print("Group 0 - 24: " + str(group_0_24))
  32. print("Group 25 - 49: " + str(group_25_49))
  33. print("Group 50 - 74: " + str(group_50_74))
  34. print("Group 75 - 99: " + str(group_75_99))
  35. print("Group 100 - 124: " + str(group_100_124))
  36. print("Group 125 - 149: " + str(group_125_149))
  37. print("Group 150 - 174: " + str(group_150_174))
  38. print("Group 175 - 200: " + str(group_175_200))

Explanation:

Firstly, open and read a text file that contains the input number (Line 1 -2).

Since each number in the text file is separated by a comma "," we can use split() method and put in "," as a separator to convert the input number string into a list of individual numbers (Line 3).

Create counter variables for each number range (Line 5 - 12).

Next create a for-loop to traverse through the number list and use if-else-if block to check the range of the current number and increment the relevant counter variable by 1 (Line 14 - 37).  

Display the count for each number range using print() function (Line 39 - 46)

You might be interested in
Describe a strategy for avoiding nested conditionals. Give your own example of a nested conditional that can be modified to beco
harina [27]

Answer:

One of the strategies to avoid nested conditional is to use logical expressions such as the use of AND & operator.

One strategy is to use an  interface class with a method. That method can be created to be used for a common functionality or purpose. This is also called strategy design pattern. You can move the chunk of conditional statement to that method. Then each class can implement that interface class and use that shared method according to their own required task by creating objects of sub classes and call that common method for any such object. This is called polymorphism.

Explanation:

Nested conditionals refers to the use of if or else if statement inside another if or else if statement or you can simply say a condition inside another condition. For example:

if( condition1) {  

//executes when condition1 evaluates to true

 if(condition2) {

//executes when condition1  and condition2 evaluate to true

 }  else if(condition3) {

 //when condition1 is true and condition3 is true

} else {

 //condition1  is true but neither condition2 nor conditions3 are true

}  }

The deeply nested conditionals make the program difficult to understand or read if the nested conditionals are not indented properly. Also the debugging gets difficult when the program has a lot of nested conditionals.

So in order to avoid nested conditionals some strategies are used such as using a switch statement.

Here i will give an example of one of the strategies i have mentioned in the answer.

Using Logical Expressions:

A strategy to avoid nested conditionals is to use logical expressions with logical operators such as AND operator. The above described example of nested conditionals can be written as:

if(condition1 && condition2){  //this executes only when both condition1 and condition2 are true

} else if(condition1 && condition3) {

this executes only when both condition1 and condition3 are true

} else if(condition1 ){

//condition1  is true but neither condtion2 nor condtion3 are true  }

This can further be modified to one conditional as:

if(!condition3){

// when  condition1 and condition2 are true

}

else

// condition3 is true

Now lets take a simple example of deciding to go to school or not based on some conditions.

if (temperature< 40){

  if (busArrived=="yes")   {

      if (!sick)       {

          if (homework=="done")           {

              printf("Go to school.");

          }

      }     

  }

}

This uses nested conditionals. This can be changed to a single conditional using AND logical operator.

if ((temperature <40) && (busArrived=="yes") &&

(!sick) && (homework=="done"))

{    cout<<"Go to school."; }

6 0
3 years ago
you're building a new network for a small financial services startup company. security is paramount, so each organization within
Elena L [17]

Since  both switch and the GBIC modules use MTRJ connectors and if a person use this to connect each module to the switch with 1 meter multimode patch cables. I will say that my response is NO, this  implementation will not work.

<h3>Why would the above implementation not work?</h3>

The reason is that a person  is not permitted to use multimode patch cables with  one or single mode GBIC modules as this is ideal.

<h3>Is GBIC still used?</h3>

Not as before, the use of GBIC is known to be considered as old or obsolete, a

The gigabit interface converter, which is GBIC module is said to be a kind of a transceiver that act to converts electric currents to a ay that is known to be optical signals.

Therefore, Since  both switch and the GBIC modules use MTRJ connectors and if a person use this to connect each module to the switch with 1 meter multimode patch cables. I will say that my response is NO, this  implementation will not work.

Learn more about  network segments from

brainly.com/question/7181203

#SPJ1

See full question below

You are building a new network for a small startup financial services company. Security is paramount, so each organization within the company will have its own network segment separated by a router. However, funds are limited, and you have been asked to keep costs to a minimum.

You have acquired a used fiber optic switch and want to use it to create a fiber optic backbone that interconnects all of the routers. You purchased several used single mode GBIC modules on eBay that you will install in each router to allow them to connect to the switch.

Both the switch and the GBIC modules use MTRJ connectors. You connect each module to the switch with 1 meter multimode patch cables.

Will this implementation work?

4 0
2 years ago
What are ya'll discords???
Mrac [35]

Answer: yall are so mean i had to edit this

Explanation: I had that for so long lol

4 0
3 years ago
Read 2 more answers
The four smallest numbers (40 points) Write an ANNA assembly program (smallest_four.ac) that finds the four smallest numbers ent
kari74 [83]

Answer:

the answer is -25

Explanation:

6 0
3 years ago
Which of the following are options when using the Select tool in Paint? (Select all that apply.)
meriva
I believe the answer is all of them except picture selection<span />
3 0
3 years ago
Other questions:
  • I’m having trouble with my computer. It’s stuck on this automatic repair screen and every time I try to reset it, it says “Your
    5·1 answer
  • A business wants to centralize its administrative tasks. At the same time, it wants the existing systems to manage and sustain t
    14·2 answers
  • Write a function "cashier" that receives an int "c" for the number of items bought. The function will ask the price and task rat
    11·1 answer
  • You are considering creating a mobile app. Describe a basic statement for the app you would create and whether your app should b
    7·1 answer
  • Your co-worker is at a conference in another state. She requests that you
    9·1 answer
  • Shipments of compact digital cameras dropped by 42% due to the industry being unable to adjust to changes in the ________. a. ec
    11·1 answer
  • 100POINTS!!!!
    9·2 answers
  • PLEASE HELP ME FIX THIS CODE.
    10·1 answer
  • Write a method that takes a Rectangle as a parameter, and changes the width so it becomes a square (i.e. the width is set to the
    8·1 answer
  • 14. My computer “boots-up” (aka activates and starts running) but it tells me that it cannot find the data to start the operatin
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!