Problem: Obscure Message
You decide to write a program that obscures a sentence for you. You will write a function Obscure() that takes three string arguments and returns one string argument. The first argument is a substitution key, the second a substitution value, and the third a sentence. The program first uses substitution to obscure the sentence and then prepends AND appends the substitution value followed by and preceded by a space " ", respectively. The program should then return the obscured sentence to the caller. You can use the following shell to start with the given parameters below:
//assignment1.js
function Obscure(sub_key, sub_value, sentence) {
// your code here
...
return obscuredSentence;
}
Example Test Case(s):
Arguments: "the", "the goat", "I want the money"
Returns: "the goat I want the goat goat money the goat"
Arguments: "the", "chicken", "I want the money"
Returns: "chicken I want chicken money chicken"
Obscure() should satisfy the following:
// Javascript Code:
var recurse_count = 0;
function Obscure(sub_key, sub_value, sentence) {
if(recurse_count==2)return sentence; // two Perform
recursion only two times
var sentence1 = sentence.replace(sub_key , sub_value);
recurse_count++;
return Obscure(sub_key , sub_value, sentence1);
}
function prepends(sub_value, sentence){
return sub_value + " " + sentence;
}
function appends(sub_value, sentence){
sentence = sentence.concat(" ");
sentence = sentence.concat(sub_value);
return sentence;
}
sub_key = "the"
sub_value = "the goat"
sentence = "I want the money"
sentence = Obscure(sub_key, sub_value, sentence);
sentence = prepends(sub_value, sentence);
sentence = appends(sub_value, sentence);
console.log(sentence);
Output:


Hit Like for Support! :)
Problem: Obscure Message You decide to write a program that obscures a sentence for you. You...
Provide the definition of class Message, which models an email message, in a file named Message.hpp and implement all the required member functions (see below) in a file named Message.cpp. A message contains a header and a body, which are separated by the first full line break in the message. The message header has a sender, a recipient, a subject representing the message heading, a Unix timestamp representing the sending time of the message, a character encoding, which you can...
1. In this lab, you will create a simple encryption function that will require a sentence and a key (both strings) as a parameter and return an encrypted version of the string. The encryption algorithm will use the exclusive OR operator (commonly abbreviated as XOR). The general structure of the encryption is that every position in the sentence is XOR'd with the accompanying position of the key. If the sentence is longer than the key, you repeat the key. For...
In C : Write a program that replaces words in a sentence. The input begins with an integer indicating the number of word replacement pairs (original and replacement) that follow. The next line of input begins with an integer indicating the number of words in the sentence that follows. Any word on the original list is replaced. You can assume the original words are unique. For coding simplicity, follow each output word by a space, even the last one. Hint:...
in c++
Program 1 Write a program that sorts a vector of names alphabetically using the selection sort and then searches the vector for a specific name using binary search. To do that, you need to write three functions I. void selSort (vector string &v: sorts the vector using selection sort 2. void display (const vector <string & v): displays the vector contents . int binSearch (const vector <ing& v, string key): searches the vector for a key returns the...
Write a program that reads a sentence input from the user. The program should count the number of vowels(a,e,i,o,u) in a sentence. Use the following function to read the sentence. Should use switch statement with toupper. int read_line(char str[],int n) { int ch, i=0; while((ch =getchar()) != '\n') if(1<n) str[i++]==ch; str[i] != '\0'; return i; } output should look like: Enter a sentence: and thats the way it is! Your sentence...
1) Echo the input: First, you should make sure you can write a program and have it compile and run, take input and give output. So to start you should just echo the input. This means you should prompt the user for the plaintext, read it in and then print it back out, with a message such as "this is the plaintext you entered:". [4 points, for writing a working program, echoing the input and submitting the program on the...
I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...
Study the VIGENÈRE CIPHER and implemented it with c++ 1.In your program, you should have two functions: encryption and decryption. 2. Use any key you like. (Don't use deceptive in the slides) 3. choose a sentence or a paragraph you like as the plaintext. I have the code I just need the implementation in a different way // C++ code to implement Vigenere Cipher #include<bits/stdc++.h> using namespace std; // This function generates the key in // a cyclic manner until...
I need help with my Java code. A user enters a sentence and the program will tell you what words were duplicated and how many times. If the same word is in the sentence twice, but one is capitalized, it will not count it as a duplicate. How can I make the program read the same word as the same word, even if one is capitalized and the other is not? For example, "the" and "The" should be counted as...
Write a C++ program that will count the number of words and vowels in a sentence. Create a bool function called isVowel that accepts a character as a parameter and returns a true if it’s a vowel (aeiou) and false otherwise. Create an int function named countVowels that will accept a string variable as a parameter and will return the number of vowels in it. Call the isVowel function as part of this process. Write an int function named countWords...