Questions
A six sided die is rolled 4 times. The number of 2's rolled is counted as...

A six sided die is rolled 4 times. The number of 2's rolled is counted as a success.

  1. Construct a probability distribution for the random variable.

# of 2's

P(X)

  1. Would this be considered a binomial random variable?
  2.    What is the probability that you will roll a die 4 times and get a 2 only once?

d) Is it unusual to get no 2s when rolling a die 4 times? Why or why not? Use probabilities to explain.

In: Statistics and Probability

A six sided die is rolled 4 times. The number of 2's rolled is counted as...

A six sided die is rolled 4 times. The number of 2's rolled is counted as a success.

  1. Construct a probability distribution for the random variable.

# of 2's

P(X)

  1. Would this be considered a binomial random variable?
  2.    What is the probability that you will roll a die 4 times and get a 2 only once?

      d Is it unusual to get no 2s when rolling a die 4 times? Why or why not? Use probabilities to explain.

In: Statistics and Probability

A report by the Traffic Injury Research Foundation stated that alcohol was a factor in 37...

A report by the Traffic Injury Research Foundation stated that alcohol was a factor in 37 % of accidents causing the fatally injury of automobile drivers. In a random sample of 12 automobile accidents resulting in the death of the driver:

a) What is the probability that alcohol was not a factor in any of the accidents?

b) What is the probability that alcohol was a factor in more than 2 but less than 7 of the accidents?

c) What is the expected number and standard deviation of accidents in which alcohol was a factor?

In: Statistics and Probability

6 women and 7 men were randomly divided into two groups, with 9 individuals in one...

6 women and 7 men were randomly divided into two groups, with 9 individuals in one group and 4 individuals in the other group.

a) Calculate the probability that there will be at least two women in each of the groups.

b)Calculate the probability that there are at least five men in the 9-person group, if we know that there is at least one women in the 4-person group.

c) Calculate the expected value of the number of women in the 9-person group.

In: Statistics and Probability

3. The distances traveled by individuals to work is exponential, with a mean of 9 miles....

3. The distances traveled by individuals to work is exponential, with a mean of 9 miles.

(a) What is the probability that they travel between 5 and 11 miles? (2)

(b) What is the 80th percentile of this distribution? (2)

4. The annual number of crimes in a city has a normal distribution, with mean 200, and standard deviation 42.

(a) What is the probability of less than 150 crimes next year? (2)

(b) What is the 75th percentile of this distribution? (2)

In: Statistics and Probability

Data from the past shows that on average, a ready-mixed concrete plant receives 100 orders for...

Data from the past shows that on average, a ready-mixed concrete plant receives 100 orders for concrete every year. The maximum number of orders that the plant can fulfill each week is 2. (a) What is the probability that in a given week the plant cannot fulfill all the placed orders? (b) Assume the answer to part (a) is 20%. Suppose there are 5 of such plants. What is the probability that in a given week 2 of the plants cannot fulfill their orders?

In: Statistics and Probability

A woman plans to bear three children. The probability of having a boy is 50%. Out...

A woman plans to bear three children. The probability of having a boy is 50%. Out of the three childer she bears, determine:
a) Mean number of boys (using the formula) (Ans: 1.5)
b) Standard Deviation of the number of boys (using the formula) (Ans: 0.866)
c) Sketch the density function of the number of boys and comment on whether the mean and standard deviation in parts a and b are plausible. (Ans: P={0.125 0.375 0.375 0.125} for 0, 1, 2, and 3 respectively)
d) Sketch the distribution function of the number of boys.

In: Statistics and Probability

Write a Java program to read in the 10 numbers in the example file Book1.csv provided...

Write a Java program to read in the 10 numbers in the example file Book1.csv provided above. The program should sum all the numbers, find the lowest number, find the highest number, and computer the average. Upon completion of the processing, the program should write a new text file named stats.txt with the information found in the following format where xxx represents a number calculated above.

The sum of the numbers is: xxx
The lowest number is: xxx
The highest number is : xxx
The average of the numbers is : xxx

Using the class Poem below. Write a complete Java program that creates three different objects of type Poem. The program shall then open a text file named poems.txt for writing and write the information about each poem to the text file. The program shall NOT write the toString() version of the object to the file, but write first the poem name on a line and then the poet name on a second line for each poem.

/**
 * Poem.java
 *
 * A class representing information about a poem for use in Chapter 5 Exercise 2
 *
 */
public class Poem
{

        private String name;
        private String poet;

        /**
         * no-arg constructor
         */
        public Poem()
        {
                // initialize attributes
                name = "unknown";
                poet = "unknown";
        }

        /**
         * @return the name
         */
        public String getName()
        {
                return name;
        }

        /**
         * @param name the name to set
         */
        public void setName(String name)
        {
                this.name = name;
        }

        /**
         * @return the poet
         */
        public String getPoet()
        {
                return poet;
        }

        /**
         * @param poet the poet to set
         */
        public void setPoet(String poet)
        {
                this.poet = poet;
        }

        @Override
        public String toString()
        {
                return "Poem [name=" + name + ", poet=" + poet + "]";
        }

}

===Exercise 3 Using the Poem class given in exercise 2, write a Java program to read from a text file named poem2.txt provided before. The program shall read the name and poet of each poem, create an object of type Poem for each name/poet pair and print all the read poem infor to the console.

We Real Cool
Gwendolyn Brooks
I Know Why the Caged Bird Sings
Maya Angelou
Hope is the Thing with Feathers
Emily Dickinson
The Road Not Taken
Robert Frost

In: Computer Science

This lab examines the various ways of working with arrays by writing pseudocode. Read the following...

This lab examines the various ways of working with arrays by writing pseudocode. Read the following programming problem prior to completing the lab.

The American Red Cross wants you to write a program that will calculate the average pints of blood donated during a blood drive. The program should take in the number of pints donated during the drive, based on a seven-hour drive period. The average pints donated during that period should be calculated and displayed. Additionally, the highest and the lowest number of pints donated should be determined and displayed. Write a loop around the program to run multiple times.

Step 1: Declare the following:

  • A global named constant MAX_HOURS with a value 7
  • A local array named pints of the data type Real of size MAX_HOURS
  • A local variable named averagePints of the data type Real
  • A local variable named highPints of the data type Real
  • A local variable named lowPints of the data type Real

// Declare global named constant below

____________________________________

Module main()

     //Declare local variables

     Declare String again = “yes”

     ____________________________________

     ____________________________________

     ____________________________________

     ____________________________________

     While again == “yes”

           // module calls below to be completed

           // in the next few steps

           Display “Do you want to run again (yes or no)? ”

           Input again

     End While

End Module

Step 2: Write a module call to a module named getPints that passes the pints array and the number of hours. Additionally, write a module header named getPints that accepts the pints array and number of hours.

                       

//Module call

Call ______________(______________, MAX_HOURS)

//Module header

Module __________(Real __________[ ] , Integer hours)

Step 3: Write a for loop inside module getPints that runs specified times using the counter variable and the two parameters. Inside the for loop, allow the user to enter values into the array.

                        Declare Integer counter = 0

           For __________________ = 0 to hours - 1

                Display “Enter pints collected:”

                Input ___________[_________]

           End For

Step 4: Write a function call to a module named getAverage that passes the pints array and the number of hours. Additionally, write a function header named getAverage that accepts the pints array and the hours variable.

                       

//Function call

Set averagePints = _____________(_____________, MAX_HOURS)

//Function header

Function _________(Real ______________[ ], Integer hours)

Step 5: Write a for loop inside function getAverage that runs hours times using the counter variable. Inside the for loop, total up the values of the array and store in the variable totalPints. Also, return the correct variable from the function.   

            Declare Integer counter

     Declare Real totalPints = 0

     Declare Real averagePints

     For __________________ = 0 to _______________

           Set _________ = ________ + ______________[________]

     End For

Set averagePints = ________________ / _________________

     Return _________________

Step 6: Write a function call to a module named getHigh that passes the pints array and the number of hours. Additionally, write a function header named getHigh that accepts the pints array and the hours variable.

                       

//Function call

Set highPints = ____________(______________, ___________)

//Function header

Function ______ _______( Real ________[ ], Integer _____)

Step 7: Write the code that will determine the highest value in an array. Also, return the correct variable from the function.   

Declare Integer index

Declare Real highest = pints[________]

For index = 1 to _____________

     If _______________[_______] > highest Then

           Set ____________ = __________[_______]

     End If

End For

Return ______________________

Step 8: Write a function call to a module named getLow that passes the pints array and the number of hours. Additionally, write a function header named getLow that accepts the pints array and the hours variable.

                       

//Function call

Set lowPints = ____________(______________, ___________)

//Function header

Function ______ _______( Real ________[ ], Integer _____)

Step 9: Write the code that will determine the lowest value in an array. Also, return the correct variable from the function. This function is very similar to getHigh function.

     _______________________________________________________

     _______________________________________________________

     _______________________________________________________

     _______________________________________________________

     _______________________________________________________

     _______________________________________________________

Step 10: Write a module call to a module named displayInfo. Pass the necessary variable to the functions that are needed to display the averagePints, the highPints, and the lowPints. Also, write the module header that accepts the same variables. Although pseudocode for this module is not required, but feel free to set it up.

            //Module call

Call displayInfo(______________, ___________, ___________)

//Module header

Module ________(Real ________, Real ________, Real _______)

In: Computer Science

Complete the following program: LinkedStack.zip package jsjf; /** * Represents a node in a linked list....

Complete the following program: LinkedStack.zip

package jsjf;

/**
* Represents a node in a linked list.
*/
public class LinearNode<T>
{
   private LinearNode<T> next;
   private T element;

   /**
   * Creates an empty node.
   */
   public LinearNode()
   {
       next = null;
       element = null;
   }

   /**
   * Creates a node storing the specified element.
   * @param elem element to be stored
   */
   public LinearNode(T elem)
   {
       next = null;
       element = elem;
   }

   /**
   * Returns the node that follows this one.
   * @return reference to next node
   */
   public LinearNode<T> getNext()
   {
       return next;
   }

   /**
   * Sets the node that follows this one.
   * @param node node to follow this one
   */
   public void setNext(LinearNode<T> node)
   {
       next = node;
   }

   /**
   * Returns the element stored in this node.
   * @return element stored at the node
   */
   public T getElement()
   {
       return element;
   }

   /**
   * Sets the element stored in this node.
   * @param elem element to be stored at this node
   */
   public void setElement(T elem)
   {
       element = elem;
   }
}
-----------------------------------------------------------------------

package jsjf;

/**
* Defines the interface to a stack collection.
*/
public interface StackADT<T>
{
   /**
   * Adds the specified element to the top of this stack.
   * @param element element to be pushed onto the stack
   */
   public void push(T element);

   /**
   * Removes and returns the top element from this stack.
   * @return the element removed from the stack
   */
   public T pop();

   /**
   * Returns without removing the top element of this stack.
   * @return the element on top of the stack
   */
   public T peek();

   /**
   * Returns true if this stack contains no elements.
   * @return true if the stack is empty
   */
   public boolean isEmpty();

   /**
   * Returns the number of elements in this stack.
   * @return the number of elements in the stack
   */
   public int size();

   /**
   * Returns a string representation of this stack.
   * @return a string representation of the stack
   */
   public String toString();

---------------------------------------------------------------------

package jsjf;

import jsjf.exceptions.*;

/**
* Represents a linked implementation of a stack.
*/
public class LinkedStack<T> implements StackADT<T>
{
   private int count;
   private LinearNode<T> top;

   /**
   * Creates an empty stack.
   */
   public LinkedStack()
   {
       count = 0;
       top = null;
   }

   /**
   * Adds the specified element to the top of this stack.
   * @param element element to be pushed on stack
   */
   public void push(T element)
   {
       LinearNode<T> temp = new LinearNode<T>(element);

       temp.setNext(top);
       top = temp;
       count++;
   }

   /**
   * Removes the element at the top of this stack and returns a
   * reference to it.
   * @return element from top of stack
   * @throws EmptyCollectionException if the stack is empty
   */
   public T pop() throws EmptyCollectionException
   {
       if (isEmpty())
           throw new EmptyCollectionException("stack");

       T result = top.getElement();
       top = top.getNext();
       count--;

       return result;
   }

   /**
   * Returns a reference to the element at the top of this stack.
   * The element is not removed from the stack.
   * @return element on top of stack
   * @throws EmptyCollectionException if the stack is empty
   */
   public T peek() throws EmptyCollectionException
   {
       // To be completed as a Programming Project
      
       return null; // temp
   }

   /**
   * Returns true if this stack is empty and false otherwise.
   * @return true if stack is empty
   */
   public boolean isEmpty()
   {
       // To be completed as a Programming Project
      
       return true; // temp
   }

   /**
   * Returns the number of elements in this stack.
   * @return number of elements in the stack
   */
   public int size()
   {
       // To be completed as a Programming Project
      
       return 0; // temp
   }

   /**
   * Returns a string representation of this stack.
   * @return string representation of the stack
   */
   public String toString()
   {
       // To be completed as a Programming Project
      
       return ""; // temp
   }
}

}
----------------------------------------------------------------------

In: Computer Science