Does anyone know how to do it on EXCEL?
Does anyone know how to do it on EXCEL?
Does anyone know how to do it on EXCEL?
Does anyone know how to do it on EXCEL? Anyone know how to do it on EXCEL?
The Statistical Abstract of the United States published by the U.S. Census Bureau reports that the average annual consumption of fresh fruit per person is 99.9 pounds. The standard deviation of fresh fruit consumption is about 30 pounds. Suppose a researcher took a random sample of 38 people and had them keep a record of the fresh fruit they ate for one year.
a) What is the probability that the sample average would be less than 90 pounds?
b) What is the probability that the sample average would be between 98 and 105 pounds?
c) What is the probability that the sample average would be less than 112 pounds?
d) What is the probability that the sample average would be more than 93 pounds?
In: Math
INSERT STRING INTO SEPARATE CHAIN HASHTABLE & ITERATE THROUGH HASHTABLE: JAVA
_________________________________________________________________________________________________________________
import java.util.*;
public class HashTable implements IHash {
// Method of hashing
private HashFunction hasher;
// Hash table : an ArrayList of "buckets", which store the actual
strings
private ArrayList<List<String>> hashTable;
/**
* Number of Elements
*/
private int numberOfElements;
private int numberOfBuckets;
/**
* Initializes a new instance of HashTable.
* <p>
* Initialize the instance variables. <br>
* Note: when initializing the hashTable, make sure to allocate each
entry in the HashTable
* to a new a HashBucket or null, your choice.
* @param numberOfBuckets the size of the hashTable
* @param hasher the type of hashing function
*/
public HashTable(int numberOfBuckets, HashFunction hasher) {
this.hasher = hasher;
this.numberOfBuckets = numberOfBuckets;
this.hashTable = new ArrayList<>();
for (int i = 0; i < numberOfBuckets; i++) {
hashTable.add(null);
}
this.numberOfElements = 0;
}
public boolean insert(String key) { // THIS METHOD NEEDS
HELP
int bucketToPlaceIn = hasher.hash(key) %
numberOfBuckets;
List<String> bucketContents =
hashTable.get(bucketToPlaceIn);
// if bucketToPlaceIn is null
// initialize bucketContents
// set hashTable at bucketToPlaceIn
equal to bucketContents
// if bucketContents doesn't contain the key
// add it
// return true
return false;
}
public boolean remove(String key) {
for (int i = 0; i < hashTable.size(); i++) {
for (int j = 0; j <
hashTable.get(i).size(); j++) {
if
(hashTable.get(i).get(j) == key) {
hashTable.get(i).remove(j);
return true;
}
}
}
return false;
}
public String search(String key) {
for (int i = 0; i < hashTable.size(); i++) {
for (int j = 0; j <
hashTable.get(i).size(); j++) {
if
(hashTable.get(i).get(j) == key) {
return key;
}
}
}
return null;
}
public int size() {
int returnSize = 0;
for (int i = 0; i < hashTable.size(); i++) {
returnSize +=
hashTable.get(i).size();
}
return returnSize;
}
public int size(int index) {
int returnSize = hashTable.get(index).size();
return returnSize;
}
// Return iterator for the entire hashTable,
// must iterate all hashBuckets that are not empty
public class HashIterator implements Iterator<String> {
// The current index into the hashTable
private int currentIndex;
// The current iterator for that hashBucket
private Iterator<String> currentIterator = null;
HashIterator() { // THIS METHOD NEEDS HELP
// YOUR CODE HERE
}
public String next() { // THIS METHOD NEEDS HELP
// YOUR CODE HERE
return null;
}
public boolean hasNext() { // THIS METHOD NEEDS HELP
// YOUR CODE HERE
return false;
}
}
// Return an iterator for the hash table
public Iterator<String> iterator() { // THIS METHOD NEEDS
HELP
// YOUR CODE HERE
return null;
}
/**
* Does not use the iterator above. Iterates over one bucket.
*
* @param index the index of bucket to iterate over
* @return an iterator for that bucket
*/
public Iterator<String> iterator(int index) {
List<String> bucket = hashTable.get(index);
return bucket != null ? bucket.iterator() : null;
}
// Prints entire hash table.
// NOTE: This method is used extensively for testing.
public void print() {
Debug.printf("HashTable size: " + size());
for (int index = 0; index < hashTable.size(); index++)
{
List<String> list = hashTable.get(index);
if (list != null) {
Debug.printf("HashTable[%d]: %d entries", index,
list.size());
for (String word : list) {
Debug.printf("String: %s (hash code %d)", word,
hasher.hash(word));
}
}else {
Debug.printf("HashTable[%d]: %d entries", index, 0);
}
}
}
}
FOR REFERENCE
// HashInterface.java - interface for hashing assignment
import java.util.Iterator;
public interface IHash {
/** Add a key to the hash table, if it is not currently in the
table
* @param key - the key to add
* @return true on success, false on failure (duplicate)
*/
public abstract boolean insert(String key);
/** Remove a key from the hash table
* @param key - the key to remove
* @return true on success, false on failure (not in table)
*/
public abstract boolean remove(String key);
/** Search for a key in the hash table
* @param key - the key to search for
* @return the key on success, null on failure (not in table)
*/
public abstract String search(String key);
/** Get the number of elements in the hash table
* @return the number of elements in the table
*/
public abstract int size();
/** Get the number of elements in the hash table at the given
index
* @param i the index in the hash table (0 to size-1)
* @return the size of the list in the i<sup>th</sup>
bucket
*/
public abstract int size(int i);
/** Get an iterator that return the Strings stored in
* the hash table one at a time. The order should be in order of
entries in
* the hash table itself and for a given bucket, the order in that
list.
* @return an Interator
*/
public abstract Iterator<String> iterator();
/** Get an iterator for the i<sup>th</sup>
bucket
* @param i the index in the hash table (0 to size-1)
* @return null if the bucket is empty, otherwise an iterator for
the bucket
*/
public abstract Iterator<String> iterator(int i);
/** Print the entire hash table.
*/
public abstract void print();
}
@FunctionalInterface
interface HashFunction {
int hash(String key);
}
public class Hasher {
// Hashing algorithms, see specification
/**
* Hashing algorithms, see provided documentation in
assignment
* @param hashFunction FIRST, SUM, PRIME, OR JAVA
* @return the corresponding HashFunction
*/
public static HashFunction make(String hashFunction) {
switch (hashFunction) {
case "FIRST":
return (String key) -> {
return
Math.abs(key.charAt(0));
};
case "SUM":
return (String key) -> {
int sumReturn = 0;
for (int i = 0; i <
key.length(); i++) {
sumReturn +=
Math.abs(key.charAt(i));
}
return sumReturn;
};
case "PRIME":
return (String key) -> {
int sumReturn = 7;
for (int i = 0; i <
key.length(); i++) {
sumReturn = (31*sumReturn) +
Math.abs(key.charAt(i));
}
return sumReturn;
};
case "JAVA":
return (String key) -> {
return key.hashCode();
};
default:
usage();
}
return null;
}
// Usage message
private static void usage() {
System.err.println("Usage: java Hasher <FIRST|SUM|PRIME|JAVA>
<word>");
System.exit(1);
}
// Test code for hasher
public static void main(String[] args) {
args = Debug.init(args);
if (args.length != 2)
usage();
HashFunction sh = make(args[0]);
int hashCode = sh != null ? sh.hash(args[1]) : 0;
System.out.printf("'%s' hashes to %d using %s\n", args[1],
hashCode, args[0]);
}
}
In: Computer Science
Reverse Polish (HP) Style Calculator - Part 2
The purpose of this assignment is to incorporate an abstract class and inheritance and add it to the interface of the business calculator created in Topic 4.
• Implement a pure abstract stack class named AbstractStack that has no implementation. It will not have a private array of double, because that is an implementation detail of ArrayStack that would not be found in other implementations such as LinkedStack. Nor will it have the constructor public AbstractClass(int size), or methods public double peek(int n) or public int count(), since these methods are convenience features that are easily implemented for ArrayStack, but not other implementations of stack.
• Include the method public double peek(), and add the method public void clear(), resulting in the following abstract methods.
o public abstract void push(double item) – Standard stack action; Throws an exception if the stack is full.
o public abstract double pop() – Standard stack action; Throws an exception if the stack is empty.
o public abstract boolean isEmpty() – Returns true if the stack is empty and false otherwise.
o public abstract double peek() – returns the value of the item located at the specified position on the stack; throws an exception if the array bounds are exceeded or if a nonexistent element is requested.
o public abstract void clear() – empties the stack if it is not already empty.
• Do not specify a constructor. Depend on the default constructor.
• Modify the existing ArrayStack.java file to include the phrase "extends AbstractStack."
• Add an implementation for the methods void clear() and double peek(), which overloads the existing double peek(int n). Provide a default constructor that creates an array that will hold three elements.
o public ArrayClass(int size) - constructor that creates an ArrayClass instance containing an array of the specified size. Remember that in Java, arrays are indexed from 0!
o public push(double item) – standard stack action; throws an exception if the array bounds are exceeded.
o public double pop() – standard stack action; throws an exception if the array bounds are exceeded.
o public boolean isEmpty() – returns true if the stack is empty and false otherwise.
o public double peek(int n) – returns the value of the item located at the specified position on the stack; throws an exception if the array bounds are exceeded or if a nonexistent element is requested; peek(0) will return the top element of the stack.
o public int count() - returns the number of items currently pushed onto the stack.
• Modify the existing TestArrayStack.java file to include tests for void clear() and double peek(). Note that it is easiest to do "incremental testing" in which you code a little then test a little.
• Create an interface with additional methods.
• Create a new file called Forth.java. Make this a publicinterface file. Add the following methods to the interface.
o public add() – pops two values from the stack, adds them together, and pushes the result back onto the stack. Throws an exception if there are not at least 2 items on the stack.
o public sub() – pops two values from the stack, subtracts the second number popped from the first number popped, and pushes the result back onto the stack. Throws an exception if there are not at least 2 items on the stack.
o public mult() – pops two values from the stack, multiplies them together, and pushes the result back onto the stack. Throws an exception if there are not at least 2 items on the stack.
o public div() – pops two values from the stack, divides the second number popped by the first number popped, and pushes the result back onto the stack. Throws an exception if there are not at least 2 items on the stack.
o public dup() – peeks at the top value on the stack and pushes a copy of that value onto the stack. Throws an exception if the stack is empty or full.
o public twoDup() – peeks at the top two values on the stack and pushes a copy of both values onto the stack (in the same order). Throws an exception if the stack does not have at least 2 items or room for 2 additional items.
• Create another file called ForthStack.java. Make this file extend ArrayStack and implement Forth. Code concrete implementations of each of the methods in the interface.
• Test by making a copy of the file TestArrayStack.java and name it TestForth. Change the name of the class inside the file. Add tests for add, sub, mult, div, dup, and twoDup.
• After thoroughly testing the program, submit the AbstractStack.java, ArrayStack.java, Forth.java, ForthStack.java, and TestForthStack.java files to the instructor.
Previous Array Stack
public class ArrayStack
{
private double[] array;
private int size;
private int num;
public ArrayStack(int a){
array = new double[a];
size = a;
num = 0;
}
public void push(double a){
if (num < size){
array[num] = a;
num++;
System.out.println("Success");
}
else {
System.out.println("Failure! Stack is full");
}
}
public double pop(){
if (num > 0){
num--;
return array[num];
}
else {
System.out.println("Stack is empty");
return -1;
}
}
public boolean isEmpty(){
return (num == 0);
}
public double peek(int n){
try
{
if (num > 0)
{
if (n < 0 || n >= num)
return -1;
else
return array[num-1-n];
}
else
{
System.out.println("Stack is empty");
return -1;
}
}
catch(Exception e ){
e.printStackTrace();
}
return 0;
}
public int count(){
return num;
}
}
Previous Test Array Stack
public class TestArrayStack{
public static void main(String [] args)
{
int choice;
int peek;
double val,poped;
boolean empty;
Scanner sc =new Scanner(System.in);
ArrayStack as = new ArrayStack(20);
while(true){
System.out.println("1. Enter a
Value in stack");
System.out.println("2. Pop a
Value");
System.out.println("3. Check If
array is Empty");
System.out.println("4. Peek
Function");
System.out.println("5.
Exit\n");
choice = sc.nextInt();
switch(choice)
{
case 1:
System.out.print("Enter a value To
push : ");
val = sc.nextDouble();
as.push(val);
break;
case 2:
poped = as.pop();
System.out.println("Popped :
"+poped);
break;
case 3:
empty = as.isEmpty();
System.out.println("Empty ?
"+empty);
break;
case 4:
System.out.print("Enter a index to
peek : ");
peek = sc.nextInt();
poped = as.peek(peek);
if(poped != -1)
System.out.println("Peeked Value :
"+poped);
else
System.out.println("Oops it was not
a valid index this place is empty");
break;
case 5:
System.exit(0);
}
}
}
}
What I need is AbstractStack.java, ArrayStack.java, Forth.java, ForthStack.java, and TestForthStack.java
Thank you
In: Computer Science
Find a primitive root modulo 2401 = 7^4. Be sure to mention which exponentiations you checked to prove that your final answer is indeed a primitive root. (You may use Wolfram Alpha for exponentiations modulo 2401, but you may not use any of Wolfram Alpha’s more powerful functions.)
In: Advanced Math
COURSE: Material Physics
3. In the process of producing ceramic powder, mesh is often used as a unit of measure for powder. Explain the meaning of the mesh! How do you get powder between 255-400 mesh?
4. Mention the various tests to find out ductile or brittle material! Explain briefly!
In: Physics
Explain how a full array in C can be expanded to hold more values. In your answer make sure you mention the function calls required, and anything else that is necessary to perform this task. Give a small example where an array of 100 integers is resized to be able to now store 200 integers.
In: Computer Science
12. There is an interesting problem occurring with (poly(ethylene terephthalate )PET recycling. Some manufacturers are including additives intended to help in the degradation of PET. Mention some additive samples.
11.Why is PEG(poly-ethylene glycol) can bewidely used in drug delivery? Hint: considering the water solubility of the polymer.
In: Chemistry
Q1:Describe the postnatal management using the BUBBLEHEE method ?
Q2:Identify the nursing management of a patient with Caesarean section ?
Q3: Mention the possible complications during postpartum period and its management ?
Q4:Describe the nursing management of a antenatal woman with eclampsia ?
Q5:Describe the danger signs during preganancy and postpartum ?
In: Nursing
Research Rule 40, which is the International Olympic Committee’s policy on restricting Olympic athletes’ ability to mention their sponsors while participating in the Games. Rule 40 particularly limits Olympic athletes’ ability to communicate sponsor messages through social media at the peak of an athlete’s visibility. Discuss both sides of this issue.
In: Economics
Discuss the differences between the accrual basis and the cash basis of accounting ( we did mention it in previous discussion forum)
What's the differences between cash flows and cash forecast?
You might want to interview a banker or small business owner, asking them how they use the particular statement in decision making
In: Accounting