Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 2, Problem 28C
Write a set of Java classes that can simulate an Internet application in which one party, Alice, is periodically creating a set of packets that she wants to send to Bob. An Internet process is continually checking if Alice has any packets to send, and if so, it delivers them to Bob’s computer; Bob is periodically checking if his computer has a packet from Alice, and if so, he reads and deletes it.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program in the Java language requires the management of university students, where student data (name, student number, and specialization) are saved, and then he can add and delete study materials for the current semester, and you can also add the grade for each subject (with the addition of the final code for the degree automatically).Note: The class principle is used to solve this assignment.
java - NetBeans
Write a Java procedural program that helps organise travellers with a specific travel company arriving at an airport, telling them which queue to join based on their hotel. The program asks each traveller what their hotel is (the choices are the Seaview for which they need to join Queue 1, the Majestic for which they need to join Queue 4 and the Grand for which they need to join Queue 7) and tells them the right queue. There are 1330 travellers with the tour company and each will use the program as they arrive. After all have indicated their hotel, the program then prints the percentage in each hotel.
* See image for an example run of the program. Percentages should be printed truncated to two decimal places. Do this using a method you write yourself that multiplies by 100, converts to an integer then divides by 100.
* must make use of a counter-controlled for loop, be in procedural programming style (not OOP)
Chapter 2 Solutions
Data Structures and Algorithms in Java
Ch. 2 - Give three examples of life-critical software...Ch. 2 - Give an example of a software application in which...Ch. 2 - Prob. 3RCh. 2 - Prob. 4RCh. 2 - Prob. 5RCh. 2 - Give a short fragment of Java code that uses the...Ch. 2 - Prob. 7RCh. 2 - Prob. 8RCh. 2 - Prob. 9RCh. 2 - Prob. 10R
Ch. 2 - Prob. 11RCh. 2 - Draw a class inheritance diagram for the following...Ch. 2 - Prob. 13RCh. 2 - Prob. 14RCh. 2 - If the parameter to the makePayment method of the...Ch. 2 - Prob. 16CCh. 2 - Most modern Java compilers have optimizers that...Ch. 2 - The PredatoryCreditCard class provides a...Ch. 2 - Modify the PredatoryCreditCard class so that a...Ch. 2 - Prob. 20CCh. 2 - Write a program that consists of three classes, A,...Ch. 2 - Prob. 22CCh. 2 - Prob. 23CCh. 2 - Write a Java class that extends the Progression...Ch. 2 - Redesign the Progression class to be abstract and...Ch. 2 - Use a solution to Exercise C-2.25 to create a new...Ch. 2 - Use a solution to Exercise C-2.25 to reimplement...Ch. 2 - Write a set of Java classes that can simulate an...Ch. 2 - Write a Java program that inputs a polynomial in...Ch. 2 - Write a Java program that inputs a document and...Ch. 2 - Prob. 31PCh. 2 - Write a Java program that simulates a system that...Ch. 2 - Define a Polygon interface that has methods area()...Ch. 2 - Prob. 35PCh. 2 - Write a Java program that can make change. Your...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Suppose each photo in Self Check 23 had a price tag. Give an algorithm for finding the most expensive photo.
Big Java Late Objects
Describe four uses of a primary key.
Database Concepts (7th Edition)
Lottery Winners Modification Modify the program you wrote for Programming Challenge 2 (Lottery Winners) so it p...
Starting Out with C++: Early Objects
Write an SQL statement to display the last name, first name, and email of any owners of cats. Use a subquery.
Database Concepts (8th Edition)
A dataset has 1000 records and 50 variables with 5% of the values missing, spread randomly throughout the recor...
Data Mining for Business Analytics: Concepts, Techniques, and Applications with XLMiner
Use the alternatives forms x(t)=N(x0H)+H(Nx0)ek(NH)t(x0H)+(Nx0)ek(NH)t=H(Nx0)ek(NH)tN(Hx0)(Nx0)ek(NH)tN(Hx0) of...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Knowledge Booster
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
- In java, implement a simple email messaging system. a message has a recipient, a sender, and a message text. a mailbox can store messages. supply a number of mailboxes for different users and a user interface for the user to login, send messages to other users, read their own messages, and log out. Given the code I have so far, what needs to be added? class Message { private String sender; private String recipient; private String messageText; public Message(String sender, String recipient) { this.sender = sender; this.recipient = recipient; this.messageText = " "; } public void append(String text) { this.messageText += text; } public String toString() { return "From: " + sender + " To: " + recipient + "\n" + this.messageText; } } class Mailbox { private ArrayList<Message> email; public Mailbox() { this.email = new ArrayList<Message>(); } public Message…arrow_forwardUSING JAVA: Implement a simple e-mail messaging system. A message has a recipient, a sender, and a message text. A mailbox can store messages. Supply a number of mailboxes for different users and a user interface for the user to login, send messages to other users, read their own messages, and log out.arrow_forwardUOWD Library is asking you to write a Java program that manages all the items in the Library. The library has books, journals, and media (DVD for example). All items have a name, author(s), and year of publication. A journal also has a volume number, while a media has a type (audio/video/interactive). The user of your program should be able to add an item, delete an item, change information of an item, list all items in a specific category (book, journal, or media), and print all items (from all categories). A menu asks the user which operation s/he wants to perform. Important: make use of collections, inheritance, interfaces, and exception handling wherever appropriate.arrow_forward
- Write a FULL Java procedural program for one human player to play a “Higher or Lower” card game. In this game, each card has a value from 1..10 inclusive. There are 4 of each value in the deck, i.e., 40 cards in total. Cards are not replaced in the deck once drawn, i.e., no more than 4 of each value will be drawn. The program starts by asking the player for a target score. The game proceeds in a series of rounds with the program repeatedly drawing and showing a card from the deck to the player one at a time. Each time, it asks the player to enter "h" (higher) or "l" (lower) to guess whether the next card drawn will be higher or lower in value. The player gains a point if they guess correctly. The game continues until the player guesses incorrectly or the target score is reached. When the game ends, it prints either a "You win!" or a "Nice try, you scored …” message as illustrated below. The image provided shows two examples of the required program behaviour: (bold is keyboard input…arrow_forwardWrite a code in Java Programming Your task is to simulate a coffee shop using the observer pattern (do not use the deprecate one). The coffee shop serves two types of coffee: espresso and cappuccino. The shop has two baristas, EspressoBarista and CappuccinoBarista. EspressoBarista generates random espresso orders between 1 and 3 every 2 seconds, while CappuccinoBarista generates random cappuccino orders between 1 and 3 every 3 seconds. The UML design diagram is shown below. Property ChangeListenerfac Observablenerfacto Coffeeshop HashMap Sting, integer> ingredients ExpresssCartate The CoffeeShop class holds the current stock of ingredients and the CoffeeShop constructor initializes the count for each ingredient. The required ingredients for each type of coffee are as follows: • Espresso: 1 shot of espresso, 1 ounce of milk Cappuccino: 1 shot of espresso, 2 ounces of milk, 1 ounce of foam If an order cannot be fulfilled because there are not enough ingredients, a warning message…arrow_forwardWrite a JAVA program which consists of a single class called BuyStuff that asks the user for two amounts, adds them, calculates tax at 15%, shows the result to the user, and asks for money. It then compares if the person gave enough money. If so, it displays the amount of change to return otherwise it displays a message asking for more money.arrow_forward
- Write a Java program that simulates a meeting reservation system. The program shall allow the user to select from the following options: Create a new meeting Show meetings on the calendar Clear all meetings Each meeting has a subject, start day/time and end day/time Subject is a short text description of the meeting Day is a date that contains month, day, and year Meeting times need only deal with hour and minute When the user wants to create a new meeting, the program asks for the subject, start and end day/times for it and adds it to the calendar For the basic requirements, meetings are not allowed to overlap. If a meeting the user wants to schedule overlaps with an existing meeting, the program presents an error message showing which meeting the one the user wants to schedule overlaps with When the user wants to show all meetings for the week, the report displays all meetings each day as follows Show all meetings in chronological order At the end of the report, show a…arrow_forwardWrite a JAVA program that simulates a circuit for controlling a hallway light that has switches at both ends of the hallway. Each switch can be up or down, and the light can be on or off. Toggling each switch turns the light on or off. (This is called a 3-way switch). Create a class called ThreeWaySwitch which simulates this situation. Provide two instance variables for the states of the two switches at each end of the hallway: private int firstSwitchState = 0, secondSwitchState= 0 ; Provide a constructor with the following heading: public ThreeWaySwitch(int initialFirstSwitch, int initialSecondSwitch) and the following methods: public int getFirstSwitchState() // 0 = down, 1 = up public int getSecondSwitchState() public int getLightState() // 0 = off, 1 = on public void toggleFirstSwitch() public void toggleSecondSwitch() Do not: provide a third instance variable for the light's state (on or off) use the ternary operator '?', or any if or switch statements in this class instead…arrow_forwardWrite a JAVA program to model the kinds of people one finds in a university. The categories are students, teachers and teaching assistant (TAs). All these categories are kinds of Person (Person is abstract class. A teaching assistant (TA) is a student and a teacher as well. A person has a name (string). A student has grade point average GPA (between 0 to 4), the teacher has the number of scholarly papers he/she has published and the teacher assistant has the number of courses he/she assists. All the classes contain constructors with default arguments to fill all data spaces. Provide display method to print all data members of an object on the screen. Classes also contain a function called isSuccessful(). Students with a GPA over 3.5 are considered successful. This function returns true if someone is successful or false if not. In main(), define an array of Person class, which can point to students, teachers and teacher assistants. The program first asks the kind of person and then lets…arrow_forward
- Design a java program that simulates a checkout line at a supermarket. The line is a queue object. Customers (i.e., customer objects) arrive in random integer intervals of from 1 to 4 minutes. Also, each customer is serviced in random integer intervals of from 1 to 4 minutes. Obviously, the rates need to be balanced. If the average arrival rate is larger than the average service rate, the queue will grow infinitely. Even with “balanced” rates, randomness can still cause long lines. Run the supermarket simulation for a 12-hour day (720 minutes), using the following algorithm: Choose a random integer between 1 and 4 to determine the minute at which the first customer arrives .At the first customer’s arrival time, do the following: Determine customer’s service time (random integer from 1 to 4). Begin servicing the customer. Schedule the arrival time of the next customer (random integer 1 to 4 added to the current time). For each minute of the day, consider the following: If the next…arrow_forwardWrite a Java program that would resemble a payroll system. An input window which will accept the employee number and the number of days of rendered work. A 2d-arraylist that contains the employee number and the rate per day is to be searched and used to compute for the gross salary. Gross salary is computed by multiplying the number of days of rendered work by rate per day of the particular employee. If the gross salary computed is greater than 100,000 the tax is 20% of the gross salary, otherwise, the tax is 10%. Deduct the tax from the gross salary to get the net pay. Display the employee number, gross salary, tax deduction, and the net pay in an output window. Design your own input/output windows. ( USE OOP CONCEPT AND JOPTION)arrow_forwardCreate a Java program that simulates a product inventory management system for a store. The program should allow users to add new products, update existing product information, and display the current inventory status. Follow these guidelines: Create a Product class with attributes like product name, price, and quantity. Implement methods to add new products to the inventory and update the information of existing products. Create an array or a collection to store instances of the Product class representing the current inventory. Display the current inventory, including details for each product. Include error handling to ensure that the inventory size is not exceeded and that users provide valid input for prices and quantities. Provide clear messages for successful actions and error cases. Include JavaDoc comments for class and method documentation. Utilize single-line comments to clarify complex statements or justify your reasoning. Maintain proper indentation and use meaningful…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License