Section B: 1. What is the output of the following program? Draw the content of Char queue. public class Vchar { public static void main(String[] args) { // TODO Auto-generated method stub Queue vChar = new Queue(); String text = " I love to learn TK1143 Program Design !"; for(int i=0; i< text.length(); i++) { char c = text.charAt(i); if (c== 'a' || c=='e' || c=='i' || c=='0' || <== 'u') vChar.enqueue (c); } System.out.println(vChar.size()); while (!vChar.isEmpty()) System.out.print(vChar.dequeue () + }

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question
Section B:
1. What is the output of the following program? Draw the content of Char queue.
public class Vchar {
public static void main(String[] args) {
// TODO Auto-generated method stub
Queue <Character> vChar = new Queue<Character>();
String text = " I love to learn TK1143 Program Design !";
for(int i=0; i< text.length(); i++) {
char c = text.charAt(i);
if (c== 'a' || c=='e' || c=='i' || c=='o' || c== 'u')
vChar.enqueue (c);
}
System.out.println(vChar.size());
while (!vChar.isEmpty())
System.out.print(vChar.dequeue () +
}
Transcribed Image Text:Section B: 1. What is the output of the following program? Draw the content of Char queue. public class Vchar { public static void main(String[] args) { // TODO Auto-generated method stub Queue <Character> vChar = new Queue<Character>(); String text = " I love to learn TK1143 Program Design !"; for(int i=0; i< text.length(); i++) { char c = text.charAt(i); if (c== 'a' || c=='e' || c=='i' || c=='o' || c== 'u') vChar.enqueue (c); } System.out.println(vChar.size()); while (!vChar.isEmpty()) System.out.print(vChar.dequeue () + }
2.
12345
Trace the given program and give the output.
class Product {
int id;
String name, category, manufacturer;
int quantity;
60
public Product (int id, String name, String category, String manufacturer, int quantity) {
this.id = id;
this.name = name;
this.category = category;
this.manufacturer = manufacturer;
this.quantity = quantity;
public static void main(String[] args) {
Queue<Product> listP = new Queue<>();
//Creating Books
Product bl=new Product (121, "Canadian Purple Wheat", "Bread", "Gardenia",8);
Product b2=new Product (233,"Ikan Sardin", "sardine", "Ayam Brands",6);
Product b3=new Product (101, "Dark Chocolate", "Chocolate", "Cadbury",4);
//Adding Product to the listp
listP.enqueue (b1);
listP.enqueue (b2);
listP.enqueue (b3);
System.out.println("Traversing the product elements:");
//Traversing list elements
for (Product b:listP) {
System.out.println(b.id+""+b.name+", "+b.category+", "+b.manufacturer+", "+b.quantity);
}
//Remove first listP element
listp.dequeue ();
System.out.println("After removing one product record: ");
for (Product b:listP) {
System.out.println(b.id+""+b.name+", "+b.category+", "+b.manufacturer+", "+b.quantity);
}
789012
10
11
12
13 }
14
15 public class ProductList {
160
17
18
19
20
21
22
23
124
25
26
27
28
m m m m m m. m 4
66789
29
30
31
32
34567
33
34
35
36
37
38
39 }
40
00 99
}
Transcribed Image Text:2. 12345 Trace the given program and give the output. class Product { int id; String name, category, manufacturer; int quantity; 60 public Product (int id, String name, String category, String manufacturer, int quantity) { this.id = id; this.name = name; this.category = category; this.manufacturer = manufacturer; this.quantity = quantity; public static void main(String[] args) { Queue<Product> listP = new Queue<>(); //Creating Books Product bl=new Product (121, "Canadian Purple Wheat", "Bread", "Gardenia",8); Product b2=new Product (233,"Ikan Sardin", "sardine", "Ayam Brands",6); Product b3=new Product (101, "Dark Chocolate", "Chocolate", "Cadbury",4); //Adding Product to the listp listP.enqueue (b1); listP.enqueue (b2); listP.enqueue (b3); System.out.println("Traversing the product elements:"); //Traversing list elements for (Product b:listP) { System.out.println(b.id+""+b.name+", "+b.category+", "+b.manufacturer+", "+b.quantity); } //Remove first listP element listp.dequeue (); System.out.println("After removing one product record: "); for (Product b:listP) { System.out.println(b.id+""+b.name+", "+b.category+", "+b.manufacturer+", "+b.quantity); } 789012 10 11 12 13 } 14 15 public class ProductList { 160 17 18 19 20 21 22 23 124 25 26 27 28 m m m m m m. m 4 66789 29 30 31 32 34567 33 34 35 36 37 38 39 } 40 00 99 }
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Stack
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning