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
VMariaS [17]
3 years ago
8

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 0.Ex: If the input is:apples 5shoes 2quit 0the output is:Eating 5 apples a day keeps the doctor away.Eating 2 shoes a day keeps the doctor away.Note: This is a lab from a previous chapter that now requires the use of a loop.import java.util.Scanner;public class LabProgram {public static void main(String[] args) {/* Type your code here. */}}

Computers and Technology
1 answer:
Marina86 [1]3 years ago
3 0

Answer:

I am writing a C++ and JAVA program.    

import java.util.Scanner; //for using input output functions

public class LabProgram { // class name

public static void main(String[] args) {//start of main function body

Scanner input = new Scanner(System.in);

// creates input instance of  Scanner type

     String str;  // declares String type variable str for a string value

     int num;  // declares integer type variable num to hold an integer value

     str = input.next(); //scans and reads input string from user

     num = input.nextInt();  //scans and reads input integer from user

//while loop continues to execute until user enters quit 0

while(str!="quit" && num!=0) {  

/* prints the following message, for example if value of num = 2 and value of str = apples then the following print statement prints Eating 2 apples a day keeps the doctor away. */

System.out.println("\nEating " + num +" " + str + " a day keeps the doctor away.");

//takes string and integer as input again and keep taking input until user //enters quit 0

str = input.next();  

num = input.nextInt(); }   } }

Explanation:

The program is well explained in the comments mentioned with each statement of the program. The program simply prompts user to enter a string and an integer. The while loop keeps executing until user enters quit 0. The program keeps taking input string and integer from user and prints the message System.out.println("\nEating " + num +" " + str + " a day keeps the doctor away.");  The loop breaks when the use enters quit 0. The screenshot of the program along with its output is attached.

You might be interested in
What Is The First Computer Brought In Nepal ? <br>​
tiny-mole [99]

Answer:

I don't know,,,(((:lol

8 0
2 years ago
A restaurant is a workplace for someone whose career specialty is in
Rashid [163]
A restaurant is a workplace for someone whos career specialty is in... Cooking

The answer is: Cooking
3 0
3 years ago
Read 2 more answers
I will give Brainliest and Extra points for correct answers!!!
AlexFokin [52]
Autauga Alabama 55,869
Baldwin Alabama 223,234
Barbour Alabama 24,686
3 0
2 years ago
Read 2 more answers
Help me with the question please..​
PIT_PIT [208]

First addition, then division

4 0
2 years ago
You work for a large company. You need to implement a backup solution for your company that will allow you to perform multiple b
Scrat [10]

Answer:

A Tape Library

Explanation:

A tape library, sometimes called a tape silo, tape robot or tape jukebox, is a storage device that contains one or more tape drives, a number of slots to hold tape cartridges, a barcode reader to identify tape cartridges and an automated method for loading tapes. It Enables faster data migrations, reduce the complexity of and increase the frequency of backups, and streamline governance in a secure and cost-effective way.

6 0
3 years ago
Other questions:
  • What type of restrictions may be placed on your license?
    7·1 answer
  • #We've started a recursive function below called #measure_string that should take in one string parameter, #myStr, and returns i
    5·1 answer
  • Phoebe has to give a permission about recycling. Where should she look while presenting?
    11·1 answer
  • In computer logic what is order of instructions
    13·1 answer
  • PLEASE HELP FAST !!!!!!!!!!
    12·1 answer
  • I think my knee....
    14·1 answer
  • I live in Pennsylvania which observes eastern standard time.
    13·1 answer
  • Simple Java programming
    15·2 answers
  • AfcAAgrwdsgsFsefvzsdfvbjhbdjbbjbjsdndVHFadbhZJBVdb
    10·2 answers
  • Question 1 of 10
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!