PRG421 Java Programming II
Need Help in PRG/421 Java Assignments?
We can help you if you are having difficulty with your PRG421 Assignment. Just email your assignments at support@assignmentcache.com.
We provide help for students all over the world.
-
PRG/421 Week 4 Java 4.5 LAB: What order? (generic methods)
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 4 Java 4.5 LAB: What order? (generic methods)
Define a generic method called checkOrder() that checks if four items are in ascending, neither, or descending order. The method should return -1 if the items are in ascending order, 0 if the items are unordered, and 1 if the items are in descending order.
The program reads four items from input and outputs if the items are ordered. The items can be different types, including integers, Strings characters, or doublesEx. If the input is
bat hat mat sat
63.2 96.5 100.1 123.5the output is
Learn More
Order: -1
Order: -1 -
PRG/421 Week 4 Java 4.6 LAB: Zip code and population (generic types)
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 4 Java 4.6 LAB: Zip code and population (generic types)
Define a class StatePair with two generic types (Type1 and type2), a constructor mutators, accessors, and a printinfo() method. Three ArrayLists have been pre-filled with StatePair data in main():
• ArrayList<StatePairInteger, String>> zipCodeState: Contains ZIP code/state abbreviation pairs
• ArrayList<StatePair<string, String>> abbrevstate: Contains state abbreviation/state name pairs
• ArrayList<StatePair<string. Integer>> state Population Contains state name/population pairsComplete main() to use an input ZIP code to retrieve the correct state abbreviation from the ArrayList ZipCodeState. Then use the state abbreviation to retrieve the state name from the ArrayList abbrevState. Lastly, use the state name to retrieve the correct state name/population pair from the ArrayList state Population and output the pair.
Ex If the input is:
21044the output is:
Learn More
Maryland: 6079602 -
PRG/421 Week 4 Java 4.13 LAB: Grocery shopping list (LinkedList)
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 4 Java 4.13 LAB: Grocery shopping list (LinkedList)
Given a ListItem class, complete the main() using the built-in LinkedList type to create a linked list called shoppingList. The program should read items from input (ending with -1), adding each item to shoppingList, and output each item in shoppingList using the printNodeData() method.
Ex. If the input is
milk
bread
eggs
waffles
cereal
-1the output is
Learn More
milk
bread
eggs
waffles
cereal -
PRG/421 Week 4 Java 4.14 LAB: Student grades (HashMap)
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 4 Java 4.14 LAB: Student grades (HashMap)
Given a HashMap pre-filled with student names as keys and grades as values, complete main() by reading in the name of a student, outputting their original grade, and then reading in and outputting their new grade.
Ex: If the input is
Quincy Wraight
73.1the output is
Learn More
Quincy Wraight's original grade: 65.4
Quincy Wraight's new grade: 73.1 -
PRG/421 Week 4 Java 4.15 LAB: Ticketing service (Queue)
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 4 Java 4.15 LAB: Ticketing service (Queue)
Given main, complete the program to add people to a queue. The program should read in a list of people's names including "You" (ending with -1), adding each person to the peopleInQueue queue. Then, remove each person from the queue until "You" is at the head of the queue. Include print statements as shown in the example below.
Ex. If the input is
Zadie Smith
Tom Sawyer
You
Louisa Alcott
-1the output is
Learn More
Welcome to the ticketing service...
You are number 3 in the queue.
Zadie Smith has purchased a ticket.
You are now number 2
Tom Sawyer has purchased a ticket.
You are now number 1
You can now purchase your ticket! -
PRG/421 Week 5 Java 5.9 LAB: All permutations of names
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 5 Java 5.9 LAB: All permutations of names
Write a program that lists all ways people can line up for a photo (all permutations of a list of Strings). The program will read a list of one-word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line.
When the input is:
Julia Lucas Mia -1then the output is (must match the below ordering):
Learn More
Julia Lucas Mia
Julia Mia Lucas
Lucas Julia Mia
Lucas Mia Julia
Mia Julia Lucas
Mia Lucas Julia -
PRG/421 Week 5 Java 5.10 LAB: Number pattern
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 5 Java 5.10 LAB: Number pattern
Write a recursive method called printNumPattern() to output the following number pattern.
Given a positive integer as input (Ex: 12), subtract another positive integer (Ex: 3) continually until 0 or a negative value is reached, and then continually add the second integer until the first integer is again reached
Ex. If the input is:
12
3the output is:
Learn More
12 9 6 3 0 3 6 9 12 -
PRG/421 Week 5 Java 5.20 LAB: Descending selection sort with output during execution
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 5 Java 5.20 LAB: Descending selection sort with output during execution
Write a void method selectionSortDescendTrace() that takes an integer array, and sorts the array into descending order. The method should use nested loops and output the array after each iteration of the outer loop, thus outputting the array N-1 times (where N is the size). Complete the main() to read in a list of up to 10 positive integers (ending in -1) and then call the selectionSortDescendTrace() method.
If the input is:
20 10 30 40 -1then the output is:
Learn More
40 10 30 20
40 30 10 20
40 30 20 10 -
PRG/421 Week 5 Java 5.21 LAB: Sorting user IDs
Regular Price: $7.00
Special Price $3.00
PRG/421 Week 5 Java 5.21 LAB: Sorting user IDs
Given a main() that reads user IDs (until -1), complete the quicksort() and partition() methods to sort the IDs in ascending order using the Quicksort algorithm, and output the sorted IDs one per line.
Ex. If the input is:
kaylasimms
julia
myron1994
kaylajones
-1the output is:
Learn More
julia
kaylajones
kaylasimms
myron1994 -
PRG 421 Week 4 Individual Analyze Assignment Analyzing a Multithreaded Program
Regular Price: $7.00
Special Price $5.00
PRG 421 Week 4 Individual Analyze Assignment Analyzing a Multithreaded Program
Deadlock occurs when no processing can occur because two processes that are waiting for each other to finish. For example, imagine that two processes need access to a file or database table row in order to complete, but both processes are attempting to access that resource at the same time. Neither process can complete without the other releasing access to the required resource, so the result is deadlock.
Read and analyze code in the linked document that spawns two different threads at the same time.
In a Microsoft® Word file, predict the results of executing the program, and identify whether a deadlock or starvation event will occur and, if so, at what point in the code.
Submit your Word file to the Assignment Files tab.
1. Predict the results of executing the program.
2. Identify whether a deadlock or starvation event will occur and, if so, at what point in the code./**********************************************************************
* Program: Week 4 Analyze a Multithreaded Program
* Purpose: Review the code and predict the results for the program execution.
* Programmer: Iam A. student
* Instructor: xxx
***********************************************************************/
Package example deadlk;public class Deadlock {
public static Object Lock1 = new Object(); // aacquires lock on the Lock1 object
public static Object Lock2 = new Object(); // aacquires lock on the Lock2 object
public static void main(String args[]) {
ThreadDemo1 T1 = new ThreadDemo1(); // define the new threads
ThreadDemo2 T2 = new ThreadDemo2(); // and set name for the threads
T1.start();
T2.start();
}private static class ThreadDemo1 extends Thread {
public void run() {
synchronized (Lock1) {
// synchronized Lock1 and Lock 2 will hold the thread until release
System.out.println("Thread 1: Holding lock 1...");
try { Thread.sleep(10); } // pause for 10 secs, then access thread
catch (InterruptedException e) {} // if exception happens, “catch it”
System.out.println("Thread 1: Waiting for lock 2..."); // display wait condition
synchronized (Lock2) {
System.out.println("Thread 1: Holding lock 1 & 2...");
}
}
}
}private static class ThreadDemo2 extends Thread {
Learn More
public void run() {
synchronized (Lock2) {
System.out.println("Thread 2: Holding lock 2...");
try { Thread.sleep(10); } // pause for 10 secs, then access thread
catch (InterruptedException e) {} // if exception happens, “catch it”
System.out.println("Thread 2: Waiting for lock 1..."); // display wait condition
synchronized (Lock1) {
System.out.println("Thread 2: Holding lock 1 & 2...");
}
}
}
}
}