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
densk [106]
3 years ago
14

You are to write a program name elevator.java that simulates one elevator services in a 12-floor building. note: there is only o

ne elevator working this building.
Computers and Technology
1 answer:
gogolik [260]3 years ago
5 0
See the attachment, if I copy if it into the Response field it gets all jumbled. Rename it to elevator.java
Download txt
You might be interested in
Lots of data can be transferred in short time, when we have,
dusya [7]

Answer: B. Higher Bandwidth

8 0
2 years ago
Read 2 more answers
41. Which is NOT a valid statement to initialize a variable?
ollegr [7]

I think its c I hope I'm not wrong about this If I am I'm sorry

5 0
3 years ago
What is an ad's target audience composed of
solmaris [256]
C. An ad targets an audience the creators hope will but the product.
3 0
4 years ago
Write a program that first reads in the name of an input file and then reads the file using the csv.reader() method. The file co
DaniilM [7]

Answer:

Here is the Python code.

import csv  

inputfile = input("Enter name of the file: ")

count = {}

with open(inputfile, 'r') as csvfile:

 csvfile = csv.reader(csvfile)

 for line in csvfile:

   for words in line:

     if words not in count.keys():

       count[words] = 1

     else:

         count[words] + 1

   print(count)

Explanation:

I will explain the code line by line.

import csv   here the css is imported in order to read the file using csv.reader() method

inputfile = input("Enter name of the file: ")  This statement takes the name of the input file from the user

count = {}  this is basically a dictionary which will store the words in the file and the number of times each word appears in the file.

with open(inputfile, 'r') as csvfile:  This statement opens the inputfile using open() method in read mode. This basically opens the input file as csv type

 csvfile = csv.reader(csvfile)  This statement uses csv.reader() method to read the csv file contents.

for line in csvfile:  This outer for loop iterates through each line of the file

for words in line:  This inner loop iterates through each word in the line

if words not in count.keys():  This if condition checks if the word is not in the dictionary already. The dictionary holds key value pair and keys() method returns a list of all the keys of dictionary

count[words] = 1  if the word is not present already then assign 1 to the count dictionary

co unt[words] + 1 if the word is already present in dictionary increment count of the words by 1. Suppose the input file contains the following words:

hello,cat,man,hey,dog,boy,Hello,man,cat,woman,dog,Cat,hey,boy

Then because of co unt[words] + 1 statement if the word appears more than once in the file, then it will not be counted. So the output will be:

{' cat': 1, ' man': 1, ' dog': 1, ' woman': 1, ' Hello': 1, ' hey': 1, ' boy': 1, 'hello': 1, ' Cat': 1}

But if you want the program to count those words also in the file that appear more than once, then change this co unt[words] + 1 statement to:  

count[words] = count[words] + 1

So if the word is already present in the file its frequency is increased by 1 by incrementing 1 to the count[words]. This will produce the following output:

{' Cat': 1, ' cat': 2, ' boy': 2, ' woman': 1, ' dog': 2, ' hey': 2, ' man': 2, ' Hello': 1, 'hello': 1}  

You can see that cat, boy, dog and hey appear twice in the file.                    

print(count) This statement prints the dictionary contents with words and their frequencies.

The program with its output is attached.

3 0
3 years ago
Next one wasss:search :(
PolarNik [594]
Uhmmmmmmmmm hmmmmmmmm
7 0
3 years ago
Read 2 more answers
Other questions:
  • What is one property of a good hash code?
    11·1 answer
  • as measuring the current, the shunt resistance of a galvanometer is needed to be zero. so why don't we put a wire parallel to th
    9·1 answer
  • __________ intelligence is an approach to boundary spanning which results from using sophisticated software to search through in
    15·1 answer
  • Which search engine do you prefer? Why
    15·2 answers
  • Which is an aspect of structural-level design?
    6·2 answers
  • A user has a network device that streams media to the LAN. The device is visible on the network. All PCs on the LAN can ping the
    13·1 answer
  • To lose weight, you must _______.
    10·2 answers
  • What’s your fave tv show?
    14·2 answers
  • In regard to segmentation, all of the following are examples of a customer's behavior or relationship with a product EXCEPT: a)
    14·1 answer
  • Develop the truth table for each of the combinational logic circuits
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!