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
Use the drop-down menus to complete statements about the two formats for importing contacts.
oee [108]

Answer:

The PST file format can only be imported into contacts by the outlook

program.

The CSV file type can be created from a document or spreadsheets

and can be imported by multiple email programs.

Explanation:

6 0
2 years ago
Read 2 more answers
Write a program that reads in an integer, and breaks it into a sequence of individual digits. Display each digit on a separate l
Montano1993 [528]

Answer:

The program in Python is as follows:

num = int(input())

for i in str(num):

   print(int(i))

Explanation:

This gets input for the number

num = int(input())

This converts the number to string and iterates through each element of the string

for i in str(num):

This prints individual digits

   print(int(i))

4 0
2 years ago
2 examples of miniature storage media ?
jeka94

Answer: Flash memory cards, USB drives and tiny hard disks.

Explanation:

6 0
3 years ago
Read 2 more answers
Class members are accessed via the ____(1)_____ operator in conjunction with the name of an object of the class, or via the ___(
Alborosie

Answer:

1.ClassName and . operator

2. ClassName and [] operator

Explanation:

There are two ways to get the members of a class first one is by using dot(.) operator.

Example : with assumption that person is a class object and age is the member in it we can use it as:

person.age

Second way is to use [] operator with member as a string in it which is used by the compiler as key to get its value.

Example : person["age"]

5 0
3 years ago
When a router forwards incoming packets closer to their destination hosts, this is called?
il63 [147K]
Port forwarding, I think.
3 0
3 years ago
Other questions:
  • In databases and database-related software, which choice is not a Boolean operator?
    7·2 answers
  • To join two or more objects to make a larger whole is to _____________ them.
    8·2 answers
  • How would you convert an integer value to a float value in Python?
    10·1 answer
  • What are two major techniques involved in green computing
    14·1 answer
  • It is used to select specific menu options, drag and drop options and to draw something on screen.
    6·1 answer
  • Which statement is true about hacking?
    11·2 answers
  • Write a function called play_round that simulates two people drawing cards and comparing their values. High card wins. In the ca
    11·1 answer
  • 9.
    8·1 answer
  • Which example illustrates the idea of "collecting data"?
    8·2 answers
  • You conduct an experiment to find the probability of a flipped coin landing on
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!