3.34 LAB: Mad Lib - loops in C++

Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.

Write a program that takes a string and integer as input, and outputs a sentence using those items as below. The program repeats until the input is quit 0.

Ex: If the input is:
apples 5
shoes 2
quit 0

the output is:
Eating 5 apples a day keeps the doctor away.
Eating 2 shoes a day keeps the doctor away.

Make sure your answer is in C++.

Answers

Answer 1

Answer:

A Program was written to carry out some set activities. below is the code program in C++ in the explanation section

Explanation:

Solution

CODE

#include <iostream>

using namespace std;

int main() {

string name; // variables

int number;

cin >> name >> number; // taking user input

while(number != 0)

{

// printing output

cout << "Eating " << number << " " << name << " a day keeps the doctor away." << endl;

// taking user input again

cin >> name >> number;

}

}

Note: Kindly find an attached copy of the compiled program output to this question.

3.34 LAB: Mad Lib - Loops In C++Mad Libs Are Activities That Have A Person Provide Various Words, Which
Answer 2

In this exercise we have to use the knowledge in computational language in C++ to describe a code that best suits, so we have:

The code can be found in the attached image.

What is looping in programming?

In a very summarized way, we can describe the loop or looping in software as an instruction that keeps repeating itself until a certain condition is met.

To make it simpler we can write this code as:

#include <iostream>

using namespace std;

int main() {

string name; // variables

int number;

cin >> name >> number; // taking user input

while(number != 0)

{

// printing output

cout << "Eating " << number << " " << name << " a day keeps the doctor away." << endl;

// taking user input again

cin >> name >> number;

}

}

See more about C++ at brainly.com/question/19705654

3.34 LAB: Mad Lib - Loops In C++Mad Libs Are Activities That Have A Person Provide Various Words, Which

Related Questions

Rewrite this if/else if code segment into a switch statement int num = 0; int a = 10, b = 20, c = 20, d = 30, x = 40; if (num > 101 && num <= 105) { a += 1; } else if (num == 208) { b += 1; x = 8; } else if (num > 208 && num < 210) { c = c * 3; } else { d += 1004; }

Answers

Answer:

public class SwitchCase {

   public static void main(String[] args) {

       int num = 0;

       int a = 10, b = 20, c = 20, d = 30, x = 40;

       switch (num){

           case 102: a += 1;

           case 103: a += 1;

           case 104: a += 1;

           case 105: a += 1;

           break;

           case 208: b += 1; x = 8;

           break;

           case 209: c = c * 3;

           case 210: c = c * 3;

           break;

           default: d += 1004;

       }

   }

}

Explanation:

Given above is the equivalent code using Switch case in JavaThe switch case test multiple levels of conditions and can easily replace the uses of several if....elseif.....else statements.When using a switch, each condition is treated as a separate case followed by a full colon and the the statement to execute if the case is true.The default statement handles the final else when all the other coditions are false
Other Questions
What products did texas supply during world war 1? Who argued to lincoln that freeing the slaves would turn Europe away from helping the south 10. Which sentence contains a proper adjective?The Marlins are Jake's favorite teGlazed doughnuts are sold out.Ed prefers Boston cream pie.Jacksonville is on the eastern seaboard of the UnitedStates. Find the areaPlease help me thank you! find the value of x in the following..... 3^x = 8 PLEASE HELP ON THIS QUESTION! I WILL MARK YOU BRAINLIEST IF CORRECT :) TYY Which expression has the same value as 5(4x+4) please answer these, it is urgent Emerson wrote about the painter early in his essay in order toA. introduce his main topic, the visual arts.B. introduce an example of someone living an inauthentic lifestyle.C. introduce the idea of trusting yourself.D. create a comic foil to use for the rest of the essay. Exercise 24-5 Payback period computation; even cash flows LO P1 Compute the payback period for each of these two separate investments: A new operating system for an existing machine is expected to cost $520,000 and have a useful life of six years. The system yields an incremental after-tax income of $150,000 each year after deducting its straight-line depreciation. The predicted salvage value of the system is $10,000. A machine costs $380,000, has a $20,000 salvage value, is expected to last eight years, and will generate an after-tax income of $60,000 per year after straight-line depreciation. How did Lincoln use the railroad to his advantage ? Object A has a mass of 10 kg and is moving at a velocity of 2.0m/s. So Object A's momentum is - kg. m/s. A scientist has two solutions, which she has labeled Solution A and Solution B. Each contains salt. She knows that Solution A is 35% salt and Solution B is 80%salt. She wants to obtain 90 ounces of a mixture that is 40% salt. How many ounces of each solution should she use?Solution A:Solution B: Which of the following best explains why the Democratic Party was formed in the 1820s? what is absolute diviation What is the discriminant of the quadratic equation 0 = x2 + 4x 2?481224 A spinner is divided into 8 equal sections numbered 1 to 8. About how many times would you expect the pointer to land on a number less than 6 if the pointer is spun 30 times. Si yo estudio, ____________ todos los exmenes. a. paso b. pasar c. pasara You flip a coin and then roll a fair six-sided die. The coin lands heads-up and the die shows an even number. help and thanks!! the blue course at the ski club is 5.8 km long. The red course is 10.3 km long. Mark skied the blue course 15 times and Katy skied the red course 15 times. How much further did Katy ski than Mark?