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

Write the statements to prompt the user to enter dog names and cat names. Each line of input contains d (dog) or c (cat) followe

d by the name. The user will enter q quit when done. Print out all the cat names followed by all the dog names. The cat names and the dog names must be output in the same order in which they were entered. Use LinkedQueue objects in your code.

Computers and Technology
1 answer:
gulaghasi [49]3 years ago
4 0

Answer:

see explaination

Explanation:

import java.util.*;

import java.util.concurrent.*;

class Main {

public static void main(String[] args)

{

Scanner sc = new Scanner(System.in); //Scanner Object to read Input

//LinkedQueue of String Type

ConcurrentLinkedQueue<String> cat_queue = new ConcurrentLinkedQueue<String>();

ConcurrentLinkedQueue<String> dog_queue = new ConcurrentLinkedQueue<String>();

System.out.println("Enter Dog names and Cat names\n");

//Reading input until line exists

while(sc.hasNextLine()){

String s = sc.nextLine(); //Reading string

String[] arr = s.split("\\s+"); //Splitting the string based on spaces

if (arr[0].equals("q") && arr[1].equals("quit")){ //checking if q quit or not

//printing cats and dogs if q quit

System.out.println("\ncats:");

//printing each cat_name in seperate line

for (String cat_name : cat_queue) { //Iterating over elements in cat_queue

System.out.println(cat_name);

}

System.out.println("\ndogs:");

//printing each dog_name in seperate line

for (String dog_name : dog_queue) { //Iterating over elements in dog_queue

System.out.println(dog_name);

}

System.exit(0); //Exiting as q quit is entered

}

else{

if(arr[0].equals("c")){ //If c is the string entered before name

cat_queue.add(arr[1]); //Add the cat_name into cat_queue

}

else if(arr[0].equals("d")){ //If d is is the string entered before name

dog_queue.add(arr[1]); //Add the dog_name into dog_queue

}

}

}

}

}

see attachment for screenshot of the code and output

You might be interested in
Calculate the shear stress (lbf/in^2) for a given normal stress (lbf/in^2) that is applied to a material with a given cohesion (
LenaWriter [7]

MOHR-COULOMB FAILURE CRITERIA:

In 1900, MOHR-COULOMB states Theory of Rupture in Materials which defines as “A material fails due to because of a critical combination of normal and shear stress, not from maximum normal or shear stress”. Failure Envelope is approached by a linear relationship.

If you can not understand the below symbols see the attachment below

 f   f ()  

Where:      f = Shear Stress on Failure Plane  

       ´= Normal Stress on Failure Plane

 See the graph in the attachment

For calculating the shear stress, when Normal stress, cohesion and angle of internal friction are given. Use this formula:   shear stress =  f  c   tan 

Where,  

• f  is Shear Stress on Failure Plane

• c  is Cohesion

•  is Normal Total Stress on Failure Plane

•  is Friction Angle

8 0
3 years ago
You can sort data in a table or_____?<br><br><br> A. Report<br> B. Form<br> C. Field<br> D. Record
Mazyrski [523]

Answer:I believe its form

Explanation:

7 0
3 years ago
Read 2 more answers
What is Deep learning
vodomira [7]

Answer:

Deep learning is an AI function that mimics the workings of the human brain in processing data for use in detecting objects, recognizing speech, translating languages, and making decisions. Deep learning AI is able to learn without human supervision, drawing from data that is both unstructured and unlabeled.

3 0
3 years ago
unittttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt
alukav5142 [94]
What the hell is the point of this, just to waist people's time?
5 0
3 years ago
As text is typed in the _____ text box, a drop-down list displays options for completing the action, displaying information on t
pickupchik [31]

Answer:

Excel Help

Explanation:

Press F1 key to open the excel help window

Or you can also click the excel help button to launch the help window.

Type for whatever you are seeking help for and you will notice suggestions as you type something. These suggestions include online and offline results. If there are too many results then try searching offline it will narrow down the results.

After typing the text and hitting enter, the excel help returns several related topics on the searched query. You can browse through these topics and get help from excel.

5 0
3 years ago
Other questions:
  • What is a block cipher algorithm that operates on 64-bit blocks and can have a key length from 32 to 448 bits?
    8·1 answer
  • Need deveolpers not software
    10·2 answers
  • Why is Abraham called the Father of Believers?
    6·1 answer
  • Call 334-399-4201 to annoyed my mom
    13·1 answer
  • why might a portrait be both a portrait of the subject and the photographer? how is a photographer present in a portrait?
    10·2 answers
  • Tell me at list 5 farm animals dieases​
    10·2 answers
  • David would like to send a letter to more than one hundred people. He would like the letter to have names and addresses inserted
    12·2 answers
  • Consider the relational schema below: Students(sid: integer, sname: string, major: string) Courses(cid: integer, cname: string,
    9·1 answer
  • Describe the scope of the variables in this code.
    8·2 answers
  • What is the full form of MOS<br>​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!