*****MUST ONLY USE******
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
Description
The word bank system maintains all words in a text file named words.txt. Each line in the text file stores a word while all words are kept in an ascending order. You may assume that the word length is less than 20.
The system should support the following three functions:
Please also make sure that
Implementation
Expected Output
Below is a sample run of the program. Assume that the file words.txt is empty initially.
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 2
Please enter the word you want to insert: cat
The word "cat" is inserted successfully!
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 2
Please enter the word you want to insert: apple
The word "apple" is inserted successfully!
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 2
Please enter the word you want to insert: dog
The word "dog" is inserted successfully!
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 1
Please enter the word you want to search for: car
The word "car" is not found!
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 1
Please enter the word you want to search for: cat
The word "cat" is found!
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 2
Please enter the word you want to insert: cat
The word "cat" already exists!
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 3
Please enter the word you want to delete: cat
The word "cat" is deleted successfully!
1 for lookup; 2 for insertion; 3 for deletion; q for quit: 3
Please enter the word you want to delete: car
The word "car" is not in the file!
Then, below is the expected content of the text file words.txt.
apple
dog
Hints
For word insertion and deletion tasks, creating a temporary file may simplify lots of work. This approach is particularly useful if the word bank is large such that you cannot read the whole word bank into memory. For the lab tasks, there are two useful functions for file operation that you may use:
In addition, we read and manipulate words through char array. The following two functions could be helpful:
======================Skeleton Code================================
#include <iostream>
#include <fstream>
#include <string.h>
#include <stdio.h>
using namespace std;
#define N 20
// search for a word in the input file, return true if found
bool lookup(const char filename[], const char word[]){
return false;
}
// delete a word in the input file
// the result should not contain blank lines
void delete_word(const char filename[], const char word[]){
}
// insert a word in the input file such that the words are in ascending order
// it should not insert duplicate word
void insert_word(const char filename[], const char word[]){
}
int main(){
const char filename[] = "words.txt";
char choice;
char word[N];
while (true){
cout << "1 for lookup; 2 for insertion; 3 for deletion; q for quit: ";
cin >> choice;
if (choice == '1'){
cout << "Please enter the word you want to search for: ";
cin >> word;
if (lookup(filename, word)){
cout << "The word \"" << word << "\" is found!" << endl;
}else{
cout << "The word \"" << word << "\" is not found!" << endl;
}
}else if (choice == '2'){
cout << "Please enter the word you want to insert: ";
cin >> word;
insert_word(filename, word);
}else if (choice == '3'){
cout << "Please enter the word you want to delete: ";
cin >> word;
delete_word(filename, word);
}else if (choice == 'q'){
break;
}else{
cout << "Invalid input. Please input again." << endl;
}
cout << endl;
}
return 0;
}In: Computer Science
Create a C++ project called RobberyLanguage. Ask the user to enter a word. Write a function that will receive the word, use the word to compile a new word in Robbery language and return the new Robbery language word. In the function: Use a while loop and a newline character (‘\0’) to step through the characters in the original string. How to compile a word in Robbery language: Double each consonant and put the letter ‘o’ between the two consonants. For example:" ENTER THE WORD: Welcome
original word is welcome , Robbery language: wowelolcocomome
process returned 0 (0*0) execution time :
press any key to continue "
Example of the definition of the function: string compileRobLanWord(char word[50]) Hints: Declare a new character string for the Robbery language word. A word in Robbery language has more characters than the original word. Therefor the new string must have its own index value. How it looks like in memory: Original word: S a m \0 2 0 1 2 3 Robbery language: S o S a m o m \0 0 1 2 3 4 5 6 7 Note: Remember to add the \0 character as the last character of the new word. In the main function: Example of the call statement in the main function: newWord = compileRobLanWord(word); Display the original word and the Robbery language word.
C#(VISUAL STUDIO)
In: Computer Science
MATLAB
Program a Matlab version of Guess the Word. The word should be
determined by user input.
Once the word is determined, the game should begin by displaying
blanks (-) where
all the letters of the word are. The game should then continue to
prompt the player to
guess a letter in the word. If the player guesses a letter that is
in the word and not
already displayed, that letter should be displayed everywhere it
appears in the word.
If the player guesses a letter that is not in the word or a letter
that is in the word
but has been guessed before, one try should be added. This should
continue until the player completes either the word or until they
have reached 6 tries, at which point the game should end which the
message: "You ran out of tries and lost."
In: Computer Science
in java
Read in a word and display the requested characters from that word in the requested format. Write a Java program that
● prompts the user for a word and reads it,
● converts all characters of the input word to uppercase and display the word with a double quotation mark ( " ) at the start and end of the word,
● displays the word with all characters whose index is odd in lower case and for the rest of the characters displaying a * instead of the character,
● finally displays the original word as it was entered by the user.
Based on the previous specifications your program should behave and look exactly as shown in the cases below. Your program should work for any word entered by the user, not just the ones in the samples.
Below illustrates how your program should behave and appear.
Note that ◦ symbol indicates a space and ↵ is a new line character. All words except for user input (in blue) must be exactly as indicated in the sample. Any extra “spaces” and/or “new lines” will be graded a wrong answer.
In: Computer Science
Prove that if two non-equal letters are interchanged in a ISBN code word the error will be detected (the word is no longer an ISBN code word)
Prove that the ISBN code can detect any single error ( if a letter was transmitted incorrectly the word is no longer an ISBN code word)
In: Advanced Math
In Java.This program will translate a word into pig-latin. Pig-latin is a language game in which words in English are altered, usually by removing letters from the beginning of a word and arranging them into a suffix. The rules we will use for the pig-latin in this program are as follows: If a word starts with a consonant, split the word at the first instance of a vowel, moving the beginning consonants to the end of the word, following a '-'. Then add 'ay' at the end of the word. Vowels are: a, e, i, o, u (Notice: We are not considering y a vowel for this program) If a word starts with a vowel add the word "yay" at the end of the word following a '-'. Examples: hello translates to ello-hay flare translates to are-flay it translates to it-yay A more detailed explanation of the requirements for each method will be in the method header comments - please follow these closely. Suggested order of completion: isVowel() then pigLatin().
In: Computer Science
Need this in C++:
Suppose that you are given a set of words; and two words from the set: word 1 and word 2.
Write a program which will transform word 1 into word 2 by changing a single letter in word 1 at a time.
Every transition that word 1 takes will have to be in the set of words.
You must output the smallest sequence of transitions possible to convert word 1 into word 2.
You may assume that all the words in the dictionary are the same length.
The first line will be word 1 and word 2 separated by a comma, followed by the set of words. The set of words will be terminated by a ‘-1’.
Input:
DOG,GOD
DOG
BOG
GOG
ABH
GOD
THU
IOP
-1
Output:
DOG -> GOG -> GOD
Input:
HOUSE,JOUKS
MOUSE
HIUKE
HIUKS
HOUSH
LOUSE
HOZKS
SOUSE
HOUKS
HOUSE
HOUKE
JOUKZ
JOUKS
HOIKE
-1
Output:
HOUSE -> HOUKE -> HOUKS -> JOUKS
In: Computer Science
Problem: Read in a word and display the requested characters from that word in the requested format. Write a Java program that
● prompts the user for a word and reads it,
● converts all characters of the input word to uppercase and displays every other character starting from the 1st one,
● converts all characters of the input word to lowercase and displays every other character in reverse order starting from the last character,
● finally displays the original word as it was entered by the user.
In: Computer Science
I'm having problems with my java code not correctly spellchecking certain words.
1) Determine if a word entered by the user is spelled correctly. A word is considered correct if it's found in dictionary.txt (see required output to get file).
these are the input and output that are suppose to come out i already have the dictionary.txt i just don't know hoe to set it up someone please help me
| Standard Input | Files in the same directory |
|---|---|
glimmer hello world test tommorrow tomorrow recluse habittat exit |
|
Output Enter word to spellcheck (or exit to end)\n glimmer is spelled correctly.\n Enter word to spellcheck (or exit to end)\n hello is spelled correctly.\n Enter word to spellcheck (or exit to end)\n world is spelled correctly.\n Enter word to spellcheck (or exit to end)\n test is spelled correctly.\n Enter word to spellcheck (or exit to end)\n tommorrow is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n tomorrow is spelled correctly.\n Enter word to spellcheck (or exit to end)\n recluse is spelled correctly.\n Enter word to spellcheck (or exit to end)\n habittat is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n Ending program...\n
Test Case 2
| Standard Input | Files in the same directory |
|---|---|
fries abc apple zzzzzzzzz a exit |
|
Output Enter word to spellcheck (or exit to end)\n fries is spelled correctly.\n Enter word to spellcheck (or exit to end)\n abc is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n apple is spelled correctly.\n Enter word to spellcheck (or exit to end)\n zzzzzzzzz is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n a is spelled correctly.\n Enter word to spellcheck (or exit to end)\n Ending program...\n
Test Case 3
| Standard Input | Files in the same directory |
|---|---|
rocking chair rocking chair hieroglyphics lie detector lie detector exit |
|
Output Enter word to spellcheck (or exit to end)\n rocking is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n chair is spelled correctly.\n Enter word to spellcheck (or exit to end)\n rocking chair is spelled correctly.\n Enter word to spellcheck (or exit to end)\n hieroglyphics is spelled correctly.\n Enter word to spellcheck (or exit to end)\n lie is spelled correctly.\n Enter word to spellcheck (or exit to end)\n detector is spelled correctly.\n Enter word to spellcheck (or exit to end)\n lie detector is spelled correctly.\n Enter word to spellcheck (or exit to end)\n Ending program...\n
Test Case 4
| Standard Input | Files in the same directory |
|---|---|
mailbox mailing miling list mailan mail order maim exit |
|
Output Enter word to spellcheck (or exit to end)\n mailbox is spelled correctly.\n Enter word to spellcheck (or exit to end)\n mailing is spelled correctly.\n Enter word to spellcheck (or exit to end)\n miling list is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n mailan is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n mail order is spelled correctly.\n Enter word to spellcheck (or exit to end)\n maim is spelled correctly.\n Enter word to spellcheck (or exit to end)\n Ending program...\n
Test Case 5
| Standard Input | Files in the same directory |
|---|---|
NE neard nearby nearly nearsghted neat exit |
|
Output Enter word to spellcheck (or exit to end)\n NE is spelled correctly.\n Enter word to spellcheck (or exit to end)\n neard is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n nearby is spelled correctly.\n Enter word to spellcheck (or exit to end)\n nearly is spelled correctly.\n Enter word to spellcheck (or exit to end)\n nearsghted is not spelled correctly.\n Enter word to spellcheck (or exit to end)\n neat is spelled correctly.\n Enter word to spellcheck (or exit to end)\n Ending program...\n
Here's the current java code that I am using (in IntelliJ):
import java.lang.*;
import java.util.*;
import java.io.*;
public class PS6LoopsPart2Q5p2 {
public static void main(String[] args) throws Exception
{
RandomAccessFile br=new RandomAccessFile("dictionary.txt","r");
Scanner input = new Scanner(System.in);
String s;
while(true)
{
System.out.println("Enter word to spellcheck (or exit to end)");
String key=input.nextLine();
if (key.equalsIgnoreCase("exit"))
{
System.out.println("Ending program...");
System.exit(0);
}
else
{
while ((s=br.readLine())!=null){
if(!s.contains(key))
{
System.out.println(key+" is spelled correctly.");
break;
}
else
{
System.out.println(key+" is not spelled correctly.");
break;
}
}
}
}
}
}
In: Computer Science
# Do not delete this cell. You have to run this cell to test
your code in the test cases.
score = dict()
# This function will search the given text in order to find a given word
def is_word_there(text, word):
"""
What it takes?
a text to be searched
a word to be searched within a text
what it does?
searches if a word occurs in a text
What it returns?
returns 1 if word is in the text.
returns -1 if word is not in the text
"""
# your code goes in here
return
Test Case for Question 1. Do not delete or alter the cell below
score = dict()
text = """ Python is an amazing programming language.
Python is also one of the primary languages in the data analysis
field"""
word = "amazing"
try:
if is_word_there(text, word) ==1:
score['question 1'] =
'pass'
else:
score['question 1'] =
'fail'
except:
score['question 1'] = 'fail'
is_word_there(text, word)
In: Computer Science