Questions
Write a java program to reverse element of a stack. For any given word (from input),...

Write a java program to reverse element of a stack. For any given word (from input), insert every character (from the word) into a stack. The output from the stack should be the same as the input. Your program should be using a stack and a queue to complete this process. 1. Push into stack 2. Pop from stack 3. Enqueue into queue 4. Dequeue from queue 5. Push into stack 6. Pop from stack and display java

In: Computer Science

1. Write a program that analyzes savings and expenses (variables of type double). Prompt the user...

1. Write a program that analyzes savings and expenses (variables of type double). Prompt the user for and retrieve these two values that have been given values. The program outputs the word Solvent, decreases the value of savings by the value of expenses, and sets the value of expenses to zero if the savings is at least as large as expenses. If, however, savings is less than expenses, the program simply outputs the word Bankrupt and does not change the value of any variables. pls write code in c++

In: Computer Science

Individuals experience various mood states or emotions at varying times every day, both subtle changes and...

Individuals experience various mood states or emotions at varying times every day, both subtle changes and obvious changes, that can result in attitude alternations with both negative and positive effects and impair or facilitate performance. The connections in the brain between emotion and memory have been particularly interesting to researchers given that neural networks that are activated by mood states are linked with neural networks that process basic perceptual functions such as word processing. Dr. Siebert has conducted a number of research experiments inducing various mood states through the use of music and then studying the effects of mood on lexical processing. (Dr. Pennie S. Siebert)

Previous research has shown that mood effects can be found in brain function at the level of lexical access. According to the associative network model of memory and emotion, emotions are represented in networks of nodes, as are words. Stimulation of emotion nodes activates networks that prime the retrieval of word nodes, creating mood-related effects on word retrieval such that positive emotions are associated with faster retrieval of positive words and negative moods are associated with faster retrieval of negative words. However, the speed of word retrieval may vary by type of mood, indicating stronger mood-related effects for some emotions compared to others. To assess differences in the speed of word retrieval under the influence of various mood states, researchers randomly assigned participants to happy, sad or neutral mood conditions and then tested their lexical retrieval of emotion-laden words.Participants were randomly assigned to listen to 30 minutes of happy, sad, or neutral music. They were then given a Reicher test which briefly presents a short string of letters that may or may not form a word. Participants were tasked with deciding whether or not the letters represented a word. Reaction time on the Reicher test was recorded for the three groups. Lower reaction time scores indicate greater mood effects on memory.

Research Question: Is there a difference in word recall among individuals who listen to happy, sad and neutral music?

Sad: 384.82, 380.26, 324.24, 314.68, 336.74, 380.26, 404.62, 331.46, 338.04, 418.28 [T=3613.98; M=361.40]

Neutral: 466.32, 430.94, 332.28, 338.04, 418.28, 597.08, 482.74, 436.74, 442.28, 580.34 [T=4525.04; M=452.50]   

Happy: 397.08, 482.74, 332.60, 397.92, 418.94, 519.54, 387.74, 442.62, 376.50, 360.34 [T=4116.08; M=411.61]

1. Write null and alternative hypotheses (in words and notation) appropriate for this research scenario.

2. Explain the concepts of SSbetween, SSwithin, SStotal, MSbetween, and MSwithin. With respect to this specific dataset, interpret what are those numbers are telling you?

3. Using the ANOVA Formula Worksheet, compute an ANOVA to test the hypotheses at an α = .05.

4. Compute the η2 and interpret it. What might be variables that would influence mood other than listening to certain types of music?

In: Statistics and Probability

word level palindrome program with stacks and queues I have a good portion of my program...

word level palindrome program with stacks and queues

I have a good portion of my program finished, I am just trying to figure out how to do some final things to it. I want the program to only check for letters a through z and A = Z, treating uppercase and lower case as the same thing. I want it to ignore any other characters and to just realize word level palindromes, not sentence level, so for example a%345b@a c24&c8d)9cc would be a word level palindrome since the program would ignore the numbers and special characters and only look at each word or set of letters as a candidate. Since uppercase and lowercase will be treated the same, something like AbBa baB should also come back as a word level palindrome. Here is the code I have so far. Thanks for any help.

include <cassert> // Provides assert

include <cctype> // Provides isalpha, toupper

include <iostream> // Provides cout, cin, peek

include <queue> // Provides the queue template class

include <stack> // Provides the stack template class

using namespace std;

int main() {

queue<char> q;
stack<char> s;
char letter;
queue<char>::size_type mismatches = 0;  // Mismatches between queue and stack
cout << "Enter a line and I will see if it's a palindrome:" << endl;

while (cin.peek() != '\n')
{
    cin >> letter;

    if (isalpha(letter))
    {
        q.push(toupper(letter));
        s.push(toupper(letter));
    }
}

while ((!q.empty()) && (!s.empty()))
{
    if (q.front() != s.top())
        ++mismatches;
    q.pop();
    s.pop();
}

if (mismatches == 0)
    cout << "That is a palindrome." << endl;
else
    cout << "That is not a palindrome." << endl;


cin.ignore(2);


return 0;

}

In: Computer Science

PYTHON PROGRAM Requirements: 1. Create an empty directory a variable named song_search 2. Repeatedly prompt the...

PYTHON PROGRAM

Requirements:

1. Create an empty directory a variable named song_search

2. Repeatedly prompt the user to enter either the title of a song or enter nothing if they have no more songs to enter

3. For each song title entered by the user, split the song title into words by using the split function and splitting on a space. For each word from each song title, ensure the song_search dictionary has a entry with that word as the key and a list (initially empty) as the value

4. Also for each song title entered by the user and each word from each song title, insert the full song title into the list inside the song_search dictionary associated with each of the words from the song. For example, the contents of the song_search dictionary after the user would have entered the song titles Crazy in Love and What is Love:

song_search = {’Crazy’ : [ ’Crazy in Love’ ],’in’ : [ ’Crazy in Love’ ],’Love’ : [ ’Crazy in Love’, ’What is Love’ ],’What’ : [ ’What is Love’ ],’is’ : [ ’What is Love’ ]}

Once the user has finished entering song titles, repeatedly ask the user if they want to look up a song by keyword until they say no. If they respond yes prompt them for a keyword and print all the song titles containing that word by looking up the value in the song_search dictionary using the key word as the key

5. If the keyword the user entered is in more than one song title, print each song title on a separate line preceeded by a number beginning with one and increasing by one for each song

6. If the keyword the user entered is in none of the song titles print the message Keyword not found in any song titles

In: Computer Science

C++. Write a program that asks the user to enter a single word and outputs the...

C++.

Write a program that asks the user to enter a single word and outputs the series of ICAO words that would be used to spell it out. The corresponding International Civil Aviation Organization alphabet or ICAO words are the words that pilots use when they need to spell something out over a noisy radio channel.

See sample screen output for an example:

 
    Enter a word: program    
    Phonetic version is: Papa Romeo Oscar Golf Romeo Alpha Mike


The specific requirement is that you write the program so that it determines the word corresponding to a specified letter using a Switch statement instead of an If structure.
As a point of reference, the ICAO alphabet is included below:

 
        A       Alpha           N       November
        B       Bravo           O       Oscar
        C       Charlie         P       Papa
        D       Delta           Q       Quebec
        E       Echo            R       Romeo
        F       Foxtrot         S       Sierra
        G       Golf            T       Tango
        H       Hotel           U       Uniform
        I       India           V       Victor
        J       Juliet          W       Whiskey
        K       Kilo            X       X-Ray
        L       Lima            Y       Yankee
        M       Mike            Z       Zulu

HINT: You may consider using character (char) array related processing or if you prefer to work with strings, determine the length of the variable string word and iterate through each letter in the string word using a for loop with a nested switch statement that has the necessary case labels matching the ICAO alphabets. Suggest converting all letters to uppercase to match the ICAO alphabet format.

Be sure to use proper formatting and appropriate comments in your code. Provide appropriate prompts to the user. The output should be clearly labeled and neatly formatted.

In: Computer Science

Hey, please write in c++. This a two-part lab but I did not put them on...

Hey, please write in c++. This a two-part lab but I did not put them on a separate question then it would be confusing to the who is answering it. The first part is already done and the code is down below but I wanted to provide the instructions for it just in case.

Please follow the instructions and provide comments helps me understand if you could, make sure the code meets all the criteria, It should be an easy assignment it should be creating a hangman game.

Please Help and thank you.
use the same code for part 2 use the code I provide, don't make separate codes for each part.

If you have any questions please let me know

-----------------------------------------------------------------

First part

  • This program is part 1 of a larger program. Eventually, it will be a complete Hangman game.
  • For this part, the program will
    • Prompt the user for a game number,
    • Read a specific word from a file,
    • Loop through and display each stage of the hangman character
      • I recommend using a counter while loop and letting the counter be the number of wrong guesses. This will help you prepare for next week
    • Print the final messages of the game.
    • NOTE: Look at the sample run for the prompt, different hangman pictures, and final messages.
  • You must have at least 3 functions other than main:
    • Function to prompt the user for a game number.
    • Function to read the appropriate word from the file based on the game number
      • If number is 1, then read the first word
      • If number is 2, then read the second word and so on
    • Function to print the correct hangman picture based on the number of wrong guesses

I already have the file don't worry about it

  • The file with the game words is called, word.txt. An example is:
moon
racecar
program
cat
word

Sample Run #1 (bold, underlined text is what the user types):

Game? 3

L----+----
|
|
|
X

L----+----
|    O
|
|
X

L----+----
|    O
|    |
|
X

L----+----
|    O
|   /|
|
X

L----+----
|    O
|   /|\
|
X

L----+----
|    O
|   /|\
|   / 
X

L----+----
|    O
|   /|\
|   / \
X

You lost
Answer: program

This the code for this first part, use it to do the second part, please.

#include <iostream>
#include <fstream>

using namespace std;

int main()
{

int hangman_level = 0;
int game_no;
int guess_char;
int word_len;
int match_count = 0;
string word;
/*
*
* Getting initial inputs from user
*
*/
game_no = getGameNumberFromUser();
word = getWordFromFile(game_no);
word_len = word.length();
  
/*
* Drawing initial hangman figure
*/
drawHangman(hangman_level);
  
while (true)
{
/*
* Iterate until win or loose
*/
guess_char = getGussedCharFromUser();
  
/*
* Compare guessed char with word char
*/
if (guess_char == word[match_count])
{
match_count++;
}
else
{
hangman_level++;
}
  
/*
* Draw next level hangman figure
*/
drawHangman(hangman_level);
  
/*
* Checking if hangman drwan completely
* if so the user will loose geme
*/

void drawHangman(int level)
{
/*
* Drawing hangman levels
*/
switch (level)
{
case 0:
cout << 'L' << "----+----" << endl;
cout << '|' << endl << "|" << endl << "|" << endl << "X" << endl;
break;
case 1:
cout << 'L' << "----+----" << endl;
cout << "| O" << endl << "|" << endl << "|" << endl << "X" << endl;
break;
case 2:
cout << 'L' << "----+----" << endl;
cout << "| O" << endl << "| |" << endl << "|" << endl << "X" << endl;
break;
case 3:
cout << 'L' << "----+----" << endl;
cout << "| O" << endl << "| /|" << endl << "|" << endl << "X" << endl;
break;
case 4:
cout << 'L' << "----+----" << endl;
cout << "| O" << endl << "| /|\\" << endl << "|" << endl << "X" << endl;
break;
case 5:
cout << 'L' << "----+----" << endl;
cout << "| O" << endl << "| /|\\" << endl << "| /" << endl << "X" << endl;
break;
case 6:
cout << 'L' << "----+----" << endl;
cout << "| O" << endl << "| /|\\" << endl << "| / \\" << endl << "X" << endl;
break;
}
}

/*
* Getting a word from file
*/
string getWordFromFile(int pos)
{

string word;
ifstream ifstr;
ifstr.open("word.txt");
for (int i = 0; i < pos - 1; i++)
{
ifstr >> word;
}
ifstr >> word;
ifstr.close();
return word;
}

/*
* Getting game number from user
*/
int getGameNumberFromUser()
{

int game_no;
cout << "Enter game number: ";
cin >> game_no;
return game_no;
}

int getGussedCharFromUser()
/*
* Getting a guessed character from user
*/
{
char guess_char;
cout << "Enter ypur guess: ";
cin >> guess_char;
return guess_char;
}

if (hangman_level == 6)
{
cout << "You lost !!!" << endl;
cout << "Correct word: " << word << endl;
break; // break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop
}
  
/*
* checking if whole word guessed correctly
* if so, user win
*/
if (match_count == word_len)
{
cout << "Congrats you won !!!" << endl;

break; // break statement is encountered inside a loop, the loop is immediately terminated and program control resumes at the next statement following the loop
}
}
  
cout << "Game Over" << endl;
return 0;
}

-------------------------------------------------------

Part 2

  • This program is part 2 of the Hangman program. keep building on last week’s Hangman.cpp
  • For this part, the program will need to:
    • If the user enters a number less than 1 for the game, then randomly select a game between 1 and 5
    • Add a function to make a copy of the word. Replace all characters with a ‘*’. You can use this to display the current state of the hangman game to the user
      • You can get the number of characters in string s, by calling s.length()
      • You can access a single character in the string with s.at(i) where i is a number between 0 and the length-1. For example, s.at(i) = ‘*’ will change the first character of s to ‘*’
      • And here’s an example to print each character in the string, one per line:
        • for (int i = 0; i < s.length(); i++)
        • {
          • cout << s.at(i) << endl;
        • }
    • Add a function to let the user make the next guess.
      • It should update any of the *’s to the guess letter if it matches
      • It should update the number of wrong guesses if the guess doesn’t match any letter in the word AND print a message to the user
    • main() will need to call your 2 new functions, stop when the user has solved the puzzle or exhausted all of its wrong guesses, and it must print a congratulations message instead of the lost message if needed
    • You may add additional functions if you want.
    • Make sure that you display the current state of the game before each guess

Sample Run #1 – user wins (bold, underlined text is what the user types):

Game? 3

L----+----
|
|
|
X

*******
? a

L----+----
|
|
|
X

*****a*
? b

Oops
L----+----
|    O
|
|
X

*****a*
? c

Oops
L----+----
|    O
|    |
|
X

*****a*
? p

L----+----
|    O
|    |
|
X

p****a*
? r

L----+----
|    O
|    |
|
X

pr**ra*
? o

L----+----
|    O
|    |
|
X

pro*ra*
? g

L----+----
|    O
|    |
|
X

progra*
? m

L----+----
|    O
|    |
|
X

Congrats!
Answer: program

Sample Run #2 – user loses (bold, underlined text is what the user types):

Game? 3

L----+----
|
|
|
X

*******
? a

L----+----
|
|
|
X

*****a*
? b

Oops
L----+----
|    O
|
|
X

*****a*
? c

Oops
L----+----
|    O
|    |
|
X

*****a*
? d

Oops
L----+----
|    O
|   /|
|
X

*****a*
? e

Oops
L----+----
|    O
|   /|\
|
X

*****a*
? f

Oops
L----+----
|    O
|   /|\
|   / 
X

*****a*
? g

L----+----
|    O
|   /|\
|   / 
X

***g*a*
? h

Oops
L----+----
|    O
|   /|\
|   / \
X

You lost
Answer: program

In: Computer Science

What is the scientific explanation of daydreaming? Is there a word for it from the textbook?...

What is the scientific explanation of daydreaming? Is there a word for it from the textbook? What kind of brain activity is observed during this time? What about dreaming at night? What is the underlying mechanism of dreaming? Do other animals dream? Provide at least 3 references

In: Biology

      Design an algorithm for each of the exercises and type it into a word document....

      Design an algorithm for each of the exercises and type it into a word document. Upload the document to PE1 assignment folder.

  1. The roots of quadratic equation:

Design an algorithm to find the real roots of a quadratic equation of the form ax2+bx+c=0, where a, b, c are all real numbers and a is nonzero

In: Electrical Engineering

define these definitions along with the word and meaning of the teram these the should be...

define these definitions along with the word and meaning of the teram

these the should be define term and the definition. in International relation course

5. Interstate/international system
6. Sovereignty
7. The New Deal
8. Cold War
9. Mutually Assured Destruction (MAD)

In: Economics