In: Mechanical Engineering
import java.util.*;
class Main
{
static ArrayList<String> list;
public static List<String> createList(ArrayList<String>
arrayList)
{
list = arrayList;
return list;
}
public static void printList(ArrayList<String>
arrayList)
{
System.out.println("Printing in 4 ways\n");
// 1
System.out.println(arrayList);
//2
for(String s:arrayList)
System.out.print(s+" ");
System.out.println();
//3
System.out.println(Arrays.deepToString(list.toArray()));
//4
for(int i=0;i<arrayList.size();i++)
System.out.print(arrayList.get(i)+" ");
System.out.println();
}
public static void filterList(ArrayList<String>
arrayList)
{
System.out.println("Filtered in 2 ways\n");
ArrayList<String> copyArrayList = arrayList;
//1
for(int i=0;i<arrayList.size();i++)
{
if(arrayList.get(i).contains("chuck")) {
arrayList.remove(i);
i--;
}
}
System.out.println(arrayList);
//2
copyArrayList.removeIf(str -> str.contains("chunk"));
System.out.println(copyArrayList);
}
public static void main(String[] args) {
//Task -1
String[] array={"The", "quick", "brown", "fox", "jumped", "over",
"the", "lazy", "dog", "how", "much", "wood", "would", "a",
"woodchuck", "chuck", "if", "a", "woodchuck", "could", "chuck",
"wood"};
ArrayList<String > list = new
ArrayList<String>(Arrays.asList(array));
createList(list);
printList(list);
filterList(list);
}
}
This is the first Part of the Code: The rest underneath has yet to be answered.
List Performance – 25 Points
Generate a loop of each type (ArrayList, LinkedList)
For each list, iterate 100,000 times using random access to grab a random value from the list
You don’t need to do anything with the value
(hint – use math.random())
Time your loops and print the results
(hint – consider using java.time.Instant for your timing)
Map Creation – 25 Points
Create a method with the following signature
public static Map<String, String> createMap(MapType type)
(hint MapType should be an enum with the values HashMap and LinkedHashMap)
createMap should return a map with the following values
[ [“Hello”, “World”], [“Goodbye”, “World”], [“Pink”, “Brown”], [“Ford”, “Toyota”], [“Nittany Lions”, “Stanford”]]
Map Iteration – 25 Points
Create two maps, one with the HashMap flag one with the LinkedHashMap tag
Iterate over each list printing out the Key/Value Pairs
Note the different loop ordering
Expert Answer
In: Computer Science
case study
you are working
as an administrative assistant in a busy GP practice in a suburb
where the community consists of people newly arrived in Australia
and a younger cohort of individuals who have moved to the area and
are heroin addicts. The GP clinic is the only clinic in the area
that provides a bulk billing service and needle exchange
program.
Mrs. Rizzo is an elderly lady of 78 years, from Italy. Mrs. Rizzo was brought to Australia by her son and daughter in law after her husband died. Mrs. Rizzo does not speak any English but relies on her son to interpret for her. Mrs. Rizzo has been in Australia for over 10 years but has made no effort to learn English and except for when her son accompanies her rarely leaves the house.
On arrival at the surgery it was apparent that Mrs. Rizzo was in pain. There was a lot of yelling, gesturing, pulling of hair and crying. Another patient attending the clinic tells her to shut up™ and asks if you could put the old bag outside™. Her son became very upset and soon both the son and the other client were yelling at each other. Mrs. Rizzo continued to wail.
You need to deal with this situation but privately
you felt that Mrs. Rizzo was making a lot of fuss.
in this case study
use Gibbs cycle of reflection
In: Nursing
Out of 20 unhealthiest countries in the world in 2019, the Indigo Wellbeing Index (IWI) has identified St. Lucia as the second unhealthiest country, Barbados as the fifth unhealthiest country, Haiti as the ninth unhealthiest country, Trinidad and Tobago as the fourteenth unhealthiest country, Jamaica as the sixteenth unhealthiest country, and Dominican Republic as the nineteenth unhealthiest country. There are only three African countries in the cohort: South Africa as the first unhealthiest country, Central African Republic as the eighth unhealthiest country and Egypt as the eighteenth unhealthiest country.
(a) Discuss in the context of this sample that wealthy country is not necessarily healthy country.
(b) Suppose that you are an advisor to Barbados Ministry of Health and Wellness and that your task is to mount and defend policies to improve Barbados’s IWI ranking, for example, from 0.34 to 0.60 in the long run. Present and discuss the policies of interest.
Notes: (i) IWI goes from 0 (unhealthiest) to 1( healthiest). It is based on 10 items: blood pressure, blood glucose, obesity, depression, happiness, alcohol use, tobacco use, exercise, healthy life expectancy, and government spending on health care.
(ii) The sizes of 2019 GDP per capita (using purchasing power parity, PPP) in international $, are the following: Central African Republic 681 (2017); Haiti 1,940; Jamaica 9,726; South Africa 13,498 (2017); St. Lucia 15,225; Egypt 16,953 (2017); Barbados 18,886; Dominican Republic 19,452; and Trinidad and Tobago 33,026.
In: Economics
Which of the following is an example of a famous intervention study?:
Which of the following is an example of a famous cohort study?
One advantage of a case-control study is that they _______.
All of the following factors influence the validity of results except:
The purpose of the Institutional Review Board (IRB) is to ensure:
A false positive means that:
An estimated 24% of Americans have metabolic syndrome. Metabolic Syndrome is characterized by all of the following except:
In: Nursing
Study 4
In a study of people with Hypertension, 65,000 people with hypertension were followed for 5 years. All were screened negative for Parkinson’s diseases (PD) when they entered the study. To control their hypertension the population was taking either calcium channel blockers (CCBs), angiotensin converting enzyme inhibitors (ACEIs) or angiotensin receptor blockers (ARBs). 25,000 people were taking CCBs, 20,000 were taking ACEIs and 20,000 were taking ARBs. This study wanted to look at the exposure to CCBs and ARBs and if it led to PD. The incidence of PD in those taking CCBs was 27/1000 and the incidence for those taking ARBs was 22/1,000.
Label the table and fill it in.
1. What type of study is this?
a. cross-sectional
b. case report/series
c. ecologic
d. case-control
e. cohort
f. clinical trial
g. community intervention
2. What is the most appropriate measure of association?
a. odd ratio
b. relative risk
c. Attributable risk
d. none of these
3. Calculate the measure of association (use two decimal places).
4. How would you best describe the relationship between the exposure and the outcome?
a. no relationship
b. positive relationship
c. negative relationship
5. If appropriate, calculate the attributable risk per 1000 people (use 2 decimal places).
***would you mind showing all of your work? Thank you!
In: Statistics and Probability
IN JAVA Searching and Sorting In An Integer List
File IntegerList contains a Java class representing a list of integers. The following public methods are
provided:
? IntegerList(int size)—creates a new list of size elements. Elements are initialized to 0.
? void randomize()—fills the list with random integers between 1 and 100, inclusive.
? void print()—prints the array elements and indices
? int search(int target)—looks for value target in the list using a linear (also called sequential) search
algorithm. Returns the index where it first appears if it is found, -1 otherwise.
? void selectionSort()—sorts the lists into ascending order using the selection sort algorithm.
File IntegerListTest contains a Java program that provides menu-driven testing for the IntegerList class.
Copy both files to your directory, and compile and run IntegerListTest to see how it works. For example, create
a list, print it, and search for an element in the list. Does it return the correct index? Now look for an element
that is not in the list. Now sort the list and print it to verify that it is in sorted order.
Modify the code in these files as follows:
occurrence of oldVal in the list with newVal. If oldVal does not appear in the list, it should do nothing (but
it’s not an error). If oldVal appears multiple times, only the first occurrence should be replaced. Note that
you already have a method to find oldVal in the list; use it!
Add an option to the menu in IntegerListTest to test your new method.
of oldVal in the list with newVal. If oldVal does not appear in the list, it should do nothing (but it’s not an
error). Does it still make sense to use the search method like you did for replaceFirst, or should you do
your own searching here? Think about this.
Add an option to the menu in IntegerListTest to test your new method.
increasing) order. Use the selection sort algorithm, but modify it to sort the other way. Be sure you change
the variable names so they make sense!
Add an option to the menu in IntegerListTest to test your new method.
target assuming the list is sorted in decreasing order. If the target is found, the method should return its
index; otherwise the method should return –1. Your algorithm will be a modification of the binary search
algorithm in the text.
Add an option to the menu in IntegerListTest to test your new method. In testing, make sure your method
works on a list sorted in descending order then see what the method does if the list is not sorted
(it shouldn’t be able to find some things that are in the list).
//
****************************************************************
// IntegerListTest.java
//
****************************************************************
import java.util.Scanner;
public class IntegerListTest
{
static IntegerList list = new IntegerList(10);
static Scanner scan = new Scanner(System.in);
public static void main(String[] args)
{
printMenu();
int choice = scan.nextInt();
while (choice != 0)
{
dispatch(choice);
printMenu();
choice = scan.nextInt();
}
}
public static void dispatch(int choice)
{
int loc;
switch(choice)
{
case 0:
System.out.println("Bye!");
break;
case 1:
System.out.println("How big should the list be?");
int size = scan.nextInt();
list = new IntegerList(size);
list.randomize();
break;
case 2:
list.selectionSort();
break;
case 3:
System.out.print("Enter the value to look for: ");
loc = list.search(scan.nextInt());
if (loc != -1)
System.out.println("Found at location " + loc);
else
System.out.println("Not in list");
break;
case 4:
list.print();
break;
case 5:
System.out.println("Enter old value you want to replace: ");
int oldVal = scan.nextInt();
System.out.println("Enter new value: ");
int newVal = scan.nextInt();
list.replaceFirst(oldVal, newVal);
break;
case 6:
System.out.println("Enter the old value: ");
int oldVal2 = scan.nextInt();
System.out.println("Enter new value: ");
int newVal2 = scan.nextInt();
list.replaceAll(oldVal2, newVal2);
break;
case 7:
list.sortDecreasing();
break;
case 8:
System.out.println("What number would you like?");
int answer = scan.nextInt();
list.binarySearch(answer);
break;
default:
System.out.println("Sorry, invalid choice");
}
}
//------------------------------------------------------
// Print the user's choices
//------------------------------------------------------
public static void printMenu()
{
System.out.println("\n Menu ");
System.out.println(" ====");
System.out.println("0: Quit");
System.out.println("1: Create a new list (** do this first!!
**)");
System.out.println("2: Sort the list using selection sort");
System.out.println("3: Find an element in the list using linear
search");
System.out.println("4: Print the list");
System.out.println("5: Replace a value");
System.out.println("6: Replace all values");
System.out.println("7: Sort in decreasing number");
System.out.println("8: Find the number");
System.out.print("\nEnter your choice: ");
}
}
//
*************************************************************
// IntegerList.java
//
*************************************************************
public class IntegerList
{
int[] list; //values in the list
public IntegerList(int size)
{
list = new int[size];
}
public void randomize()
{
for (int i=0; i<list.length; i++)
list[i] = (int)(Math.random() * 100) + 1;
}
public void print()
{
for (int i=0; i<list.length; i++)
System.out.println(i + ":\t" + list[i]);
}
public int search(int target)
{
int location = -1;
for (int i=0; i<list.length && location == -1;
i++)
if (list[i] == target)
location = i;
return location;
}
public void selectionSort()
{
int minIndex;
for (int i=0; i < list.length-1; i++)
{
//find smallest element in list starting at location i
minIndex = i;
for (int j = i+1; j < list.length; j++)
if (list[j] < list[minIndex])
minIndex = j;
//swap list[i] with smallest element
int temp = list[i];
list[i] = list[minIndex];
list[minIndex] = temp;
}
}
public void replaceFirst(int oldVal, int newVal){
int something = this.search(oldVal);
if( something == -1){
System.out.println("Nothing");}
else{
list[something] = newVal;}
}
public void replaceAll(int oldVal, int newVal){
int counter = 0;
for(int i=0;i<list.length;i++){
if(list[i] == oldVal){
list[i] = newVal;
counter++;}}
if (counter == 0){
System.out.println("Could not find your number");}
}
public void sortDecreasing(){
int minIndex;
for (int i=0; i < list.length-1; i++)
{
minIndex = i;
for (int j = i+1; j < list.length; j++){
if (list[j] > list[minIndex]){
minIndex = j;}
int temp = list[i];
list[i] = list[minIndex];
list[minIndex] = temp;}
}
}
public void binarySearch(Integer target)
{
int min = 0, max = list.length - 1, mid = 0;
boolean found = false;
while (!found && min <= max)
{
mid = (min + max) / 2;
if (target.equals(list[mid]))
found = true;
else
if ((target.compareTo(list[mid])) < 0)
max = mid - 1;
else
min = mid + 1; // works in increasing order, not decreasing
:(
}
if (found)
System.out.println("found the number! the index is: " + mid);
else
System.out.println("could not find it");
}
}
In: Computer Science
An ac voltage, whose peak value is 150 V, is across a 330 -Ω resistor.
What is the peak current in the resistor? answer in A
What is the rms current in the resistor? answer in A
In: Physics
Referring to the definition of the Helmholtz energy (Eq. 6.5 in your text), show that dA represents the maximum amount of total work that a system can perform at constant T and V.
In: Chemistry
In: Computer Science