subject

CS160 Computer Science I In class Lab 10 Objective:
Work with dictionaries
Work with strings
Work with files
Assignment:
This program will read a file of English words and their Spanish translation. It then asks the user for an English word. If it exists in your dictionary the Spanish translation is displayed. If the English word does not exist in the dictionary the program states that the word does not exist in its list of words.
Specifics:
Create a text file, with one English word and a Spanish word per line, separated by a colon. You can create the language file using a text editor, you do not need to write a program to create this file. An example of the file might be:
one:uno
two:dos
three:tres
four:cuatro
five:cinco
six:seis
seven:siete
eight:ocho
nine:nueve
ten:diez
After reading the text file, using it to fill up a dictionary, ask the user for an English word. If the word exists, print out the Spanish version. If the word does not exist state that the word is not in your list. Continue this process of asking for a word until the user does not enter a word (just pressed Enter).
As you might have noticed, there is nothing in the program that limits this Spanish words. This program can be written to work with any translation, so feel free to make it be French, or German or any other language where you can come up with a list of translated words. You also are not limited to 10 words, that is just the list I came up with for the example. The number of key/values pairs that you have in your dictionary is basically limited by the memory in your computer.
Hints
You will need to determine if the key (the English word) exists in the dictionary. Use the in operator with the dictionary, or the get() method. Either can be used to avoid crashing the program, which happens if you attempt to use a key that does not exist.
An example of running the program might be:
Enter the translation file name: oneToTen. txt
> Enter an English word to receive the Spanish translation.
Press ENTER to quit.
Enter an English word: one
he Spanish translation is uno
Enter an English word: ten
The Spanish word is diez
Enter an English word: 5
I don’t have that word in my list.
Enter an English word: three
The Spanish word is tres

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:00
Write a function that draws a pool ball. this function should take as parameters, the color, the number that should go on the pool ball, and the location of the center of the pool ball. the radius of the pool balls should be pool_ball_radius, and the font of the number should be pool_ball_font. the text of the pool ball font should be white. drawpoolball(color.orange, 5, 100, 100); drawpoolball(color.green, 6, 50, 200); drawpoolball(color.red, 3, 150, 350); drawpoolball(color.blue, 2, 250, 140); to center the numbers on the pool ball, you should use the getwidth() and getheight() methods. you are allowed to call these methods on your text object, such as txt.
Answers: 3
question
Computers and Technology, 23.06.2019 11:00
This chapter lists many ways in which becoming computer literate is beneficial. think about what your life will be like once you’re started in your career. what areas of computing will be most important for you to understand? how would an understanding of computer hardware and software you in working from home, working with groups in other countries and contributing your talents.
Answers: 1
question
Computers and Technology, 23.06.2019 23:40
4. what is the reason for including the following code snippet in the header file animal.h? #ifndef animal_h #define animal_h class animal { public: animal(); animal(double new_area_hunt); void birth(); void hunt(double new_area_hunt); void death(); double get_area_hunt() const; private: double area_hunt; }; #endif
Answers: 3
question
Computers and Technology, 24.06.2019 22:30
To add additional commands to the quick access toolbar, a user can navigate to the view. backstage status bar design file
Answers: 2
You know the right answer?
CS160 Computer Science I In class Lab 10 Objective:
Work with dictionaries
Work with s...
Questions
question
Mathematics, 17.04.2020 02:26
Questions on the website: 13722367