1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Viktor [21]
4 years ago
12

Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (a

nd 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 string is quit.

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

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

Note: This requires the use of a loop.
Computers and Technology
2 answers:
oksano4ka [1.4K]4 years ago
8 0

Answer:

The program to this question can be defined as follows:

Program:

import java.util.*; //import package

public class Main //defining class

{

   public static void main(String[] as) //defining main method

   {

       Scanner ax= new Scanner(System.in);//create Scanner class object for user-input

       String val; //defining String variable

       int x;//defining an integer variable

       System.out.print("Enter string value first then numeric, and for exit 'quit & 0': \n");

       val = ax.next(); //input value

       x = ax.nextInt();//input value

       while(!(val.equals("quit") && x==0)) //Check value

       {

           System.out.println("Eating "+x+" "+val+" a day keeps the doctor away."); //print value

           val = ax.next(); //input value

           x= ax.nextInt(); //input value

       }

   }

}

Output:

Enter string value first then numeric, and for exit 'quit & 0':  

apple 5

Eating 5 apple a day keeps the doctor away.

shoes 2

Eating 2 shoes a day keeps the doctor away.

quit 0

Explanation:

In the above program, two variable "val" and "x" is declared, in which "val" is string variable and "x" is integer variable, in the next line, a while loop is declared, which can be described as follows:

In the loop, a condition is checked, that "val" is equal to "quit" and x is equal to "0", inside the loop, it will input value from the user-end.  

Alisiya [41]4 years ago
7 0

Answer:

in python:

while True:

   inter,string= input().split() #use split to write input in the same line

   if(inter=="quit"):

     break

   else:

     print("Eating {} {} a day keeps the doctor away.".format(string,inter))    

Explanation:

You might be interested in
How many of you got the right answer from this app​
Flura [38]
Actually, a lot, and it’s especially helpful when the answer is expert verified
8 0
3 years ago
Which of these lists correctly counts from 1 to 5 In binary
evablogger [386]

Answer:B

Explanation: it is b because counting to 5 in binary is 0=0 1=1 2=10 3=11 4=100 and 5=101 so when you add the exes zeros  it becomes B.

3 0
2 years ago
Guys i really need help pleasure?
miskamm [114]

How many copies to print is one of several choices
you can indicate in the print dialog.


7 0
3 years ago
Read 2 more answers
Angelika just submitted her product for the first time, and she had 2 errors, 3 warnings, and 5 notifications. What does she nee
skelet666 [1.2K]

vvhooi. cucuxcuh gxzuzn

5 0
4 years ago
Read 2 more answers
Define a method named roleOf that takes the name of an actor as an argument and returns that actor's role. If the actor is not i
dusya [7]

Answer:

var movie = {

   // Code will be tested with different actors and movies

   name: "Interstellar",

   director: "Christopher Nolan",

   composer: "Hans Zimmer",

   cast: {

       "Matthew McConaughey": "Cooper",

       "Anne Hathaway": "Brand",

       "Jessica Chastain": "Murph",

       "Matt Damon": "Mann",

       "Mackenzie Foy": "Young Murph"

   },

   roleOf: function (actorName) {

       if (!(actorName in this.cast)) {

           return "Not in this movie.";

       }

       return this.cast[actorName];

   }

};

Explanation:

4 0
3 years ago
Other questions:
  • By default, only the ________ options are allowed when the worksheet is protected.
    11·1 answer
  • You are writing a report using a template provided by your supervisor. If you increase the margins around your pages by 30 perce
    5·1 answer
  • Chandra, a student working on a group project, is trying to decide how to have the whole group suggest revisions for an essay. S
    10·1 answer
  • Question 14 (3 points)
    5·1 answer
  • Advantage of realtime processing​
    14·1 answer
  • In which type of modulation is a 1 distinguished from a 0 by shifting the direction in whichthe wave begins?
    14·1 answer
  • If you change the text to bold,you are changing the what?
    9·1 answer
  • What will you see on the next line?
    6·2 answers
  • Write a program that prints the numbers 1 - 50. If the number is even print the word 'EVEN!' next to it. If the number is odd pr
    10·1 answer
  • Swapping as applied in memory management with an aid of a diagram​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!