Questions
Suppose you build an option portfolio by placing two separate orders. First, you purchase a call...

Suppose you build an option portfolio by placing two separate orders. First, you purchase a call contract on Stock A with a striking price of $120 for a premium of $5 per share. Second, you write two put contracts on Stock B with a striking price of $80 for a premium of $4 per share. You hold the options until the expiration date, when Stock A sells for $123 per share and Stock B sells for $78 per share. What is the option portfolio’s total profit or loss?

$400 loss

$200 loss

$0

$200 profit

$400 profit

In: Finance

You’re finally ready to launch your first suite of services at your startup. You have no...

You’re finally ready to launch your first suite of services at your startup. You have no business or economic background and are unsure how to set the price. Your gut tells you to charge $700/year. Based on what we’ve learned in this course about the type of political and economic systems and price-setting strategies, explain how you would determine prices for your business. Be sure to mention the laws of supply and demand, the types of economic/political systems involved, and any key economic concepts involved. (one small paragraph in your own words)

In: Economics

Write a function called price_of_rocks. It has no parameters. In a while loop, get a rock...

Write a function called price_of_rocks. It has no parameters. In a while loop, get a rock type and a weight from the user. Keep a running total of the price for all requested rocks. Repeat until the user wants to quit. Quartz crystals cost $23 per pound. Garnets cost $160 per pound. Meteorite costs $15.50 per gram. Assume the user enters weights in the units as above. Return the total price of all of the material. Using Python

For this discussion, you should first write pseudocode for how you would solve this problem

Please write the Pseudocode for this problem.

In: Computer Science

Suppose two seemingly similar goods or services with significantly different prices. Discuss a minimum of three...

Suppose two seemingly similar goods or services with significantly different prices. Discuss a minimum of three different possible explanations of why those price differences might exist. Be specific about your assumptions. Be clear in why those goods or services have different prices and whether or not those price differences might disappear over time. Give examples of two goods that might fit each of your explanations. What generalizations about how prices relate to one another can you make? Focus on the economic concepts and focus on the first part of the question, then briefly mention the examples.

In: Economics

Critically analyze the pros and cons of putting a price ceiling on prescription medicine. Make sure...

Critically analyze the pros and cons of putting a price ceiling on prescription medicine. Make sure to use concepts from the chapter in this unit such as government intervention, inefficiencies, price elasticity, etc. in your answer.

  1. In the first case, assume the medication is for a life threatening illness for which your child has been diagnosed.
  2. In a second case, assume the medication is for an improved quality of life issue, such as achieving a healthy weight.
  3. What are the impacts that the pharmaceutical company that makes the medications in question will experience? How will that affect the pharmaceutical company’s production decisions? What about its decisions to conduct further research into new drugs?

In: Economics

I already have the code of this program, I just want to know how to fix...

I already have the code of this program, I just want to know how to fix the code to Implement the 5th function

System.nanotime() and System.currentTimeMillis() methods)

What Code does:

Introduction

Searching is a fundamental operation of computer applications and can be performed using either the inefficient linear search algorithm with a time complexity of O (n) or by using the more efficient binary search algorithm with a time complexity of O (log n).

Task Requirements

In this lab, you will write a Java program to search for an integer in an array using recursive and non-recursive binary search.

Classes:

  1. Binarysearch class

Instance variables

  1. Private data members and Scanner object.
  2. You may choose to include here all instance variables shared by both recursive and non-recursive methods. These may include shared array index and search key variables.

Methods

  1. nonRecursiveBinarySearch (uses iterative/looping construct)

Receives an array of integers and the search key – number to search. If the number is present in the array the method returns its index location and prints the message: ‘number ___ found at index ___’ on the screen. If the number is not found in the array the method returns a sentinel value of -1 and prints the message ‘number _ was not found’.

  1. recursiveBinarySearch (uses recursion)

A method that receives an array of randomly generated integers, the first index and last index of the array, and the number to search. The method then recursively searches for the number entered by the user on the keyboard. Returns the index position if the number is present in the array and prints the message ‘number ___ found at index ___’ on the screen. Returns a sentinel value of -1 if the number is not found and prints the message ‘number __ was not found’.

  1. generateRandomInts

Uses the more SecureRandom class to generate random integers between 10 and 100. Returns an array of random numbers: randomArr, that is, an array that will be populated with 20 randomly generated integer values mainly in the range of 10 to 100 – boundary values excluded i.e. 10

This method prints the sorted array of random integers on the screen.

  1. remainingElements

This method displays elements remaining each time a half of the array is dropped.

  1. System.nanotime() and System.currentTimeMillis() methods

Use these two methods of the System class to determine how long the recursive and non-recursive binary Search operations in (a) and (b) take in nanoseconds and milliseconds. Time taken by each operation should be displayed on the screen. Hint: wrap each method in (a) and (b) with the timing methods.

  1. You may create one more additional method.
  1. Lab3binsearchTest class

Creates a menu as follows:

Select your option in the menu:

  1. Initialize and populate an array of 20 random integers.
  2. Perform a recursive binary search.
  3. Perform a non-recursive binary search.
  4. Exit.

code:

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

class BinarySearch{
        
        // Non recursive binary search
        public int nonRecursiveBinarySearch(int arr[],int target)
        {
                int low=0,high=arr.length-1;
                while(low<=high)
                {
                        remainingElements(arr,low,high);
                        int mid=(low+high)/2;
                        if(arr[mid]==target)
                        {
                                System.out.println("Number "+target +" is found at index "+mid+" :Non recursive binary search");
                                return mid;
                        }
                        else if(arr[mid]<target)
                                low=mid+1;
                        else
                                high=mid-1;
                }
                System.out.println("Number "+target+" was not found   :Non recursive binary search");
                return -1;
        }
        
        // recursive binarySearch
        public int recursiveBinarySearch(int arr[],int first,int last,int target)
        {
                if(first<=last)
                {
                        remainingElements(arr,first,last);
                        int mid=(first+last)/2;
                        if(arr[mid]==target)
                        {
                                System.out.println("Number "+target +" is found at index "+mid+"  : recursive binary search");
                                return mid;
                        }
                        else if(arr[mid]<target)
                                return recursiveBinarySearch(arr,mid+1,last,target);
                        else
                                return recursiveBinarySearch(arr,first,mid-1,target);
                }
                // if not found
                System.out.println("Number "+target +" is not found : recursive binary search");
                return -1;
                
        }
        
        // display method will the array content between two index
        public void remainingElements(int arr[],int l,int r)
        {
                for(int i=l;i<=r;i++)
                        System.out.print(arr[i]+" ");
                System.out.println();
        }
        
        int[] generateRandomInts()
        {
                int arr[]=new int[20];
                Random rand=new Random();
                for(int i=0;i<20;i++)
                        arr[i]=rand.nextInt(89)+11; // generate between 11 to 99
                // sort the array
                Arrays.sort(arr);
                return arr;
        }
        
        public void calculateTime(int arr[],int target)
        {
                // for recusive 
                long start=System.nanoTime();
                recursiveBinarySearch(arr,0,arr.length-1,target);
                long time=System.nanoTime()-start;
                System.out.println("Recursive method will take "+time+"ns");
                
            start=System.currentTimeMillis();
                recursiveBinarySearch(arr,0,arr.length-1,target);
                time=System.currentTimeMillis()-start;
                System.out.println("Recursive method will take "+time+"ms");
                
                
                // for non  recusive 
                          start=System.nanoTime();
                                nonRecursiveBinarySearch(arr,target);
                                 time=System.nanoTime()-start;
                                System.out.println("Non Recursive method will take "+time+"ns");
                                
                            start=System.currentTimeMillis();
                                nonRecursiveBinarySearch(arr,target);
                                time=System.currentTimeMillis()-start;
                                System.out.println("Non Recursive method will take "+time+"ms");
                                
                                
                
        }
        
        
        
}


public class Lab3binarysearchTest {
        

        public static void main(String[] args) {
                
       Scanner sc=new Scanner(System.in);
       BinarySearch bs=new BinarySearch();
       int arr[] = null;
       while(true)
       {
           System.out.println("Select your option int the menu below:\n"
                        + "1.Initialize and populate an array of 20 random integers\n"
                        + "2.Perform a recursive binary search\n"
                        + "3.Perfrom a non-recursive binary search\n"
                        + "4.Exit");
           int choice=sc.nextInt();
           if(choice==1)
           {
                   arr=bs.generateRandomInts();
                   System.out.println("Array of randomly generated integers:");
                   bs.remainingElements(arr, 0, arr.length-1);
                   
           }
           else if(choice==2)
           {
                   System.out.print("Please enter an integer value to search: ");
                int target=sc.nextInt();
                bs.recursiveBinarySearch(arr, 0, arr.length-1, target);
           }
           else if(choice==3)
           {
                   System.out.print("Please enter an integer value to search: ");
               int target=sc.nextInt();
               bs.nonRecursiveBinarySearch(arr, target);
           }
           else if(choice==4)
                   System.exit(0);
           else
                   System.out.println("Enter a valid choice");
           
       }
                
        }

}

In: Computer Science

Within Store.java, the refundOrder method has been started for you. Do not modify it’s method signature....

Within Store.java, the refundOrder method has been started for you. Do not modify it’s method signature. Ensure you understand how it works.

Complete the refundOrder method (method stub provided for you) so that it:

- Searches through the Store’s ArrayList of Order objects (hint: this method is in the same class as the ArrayList attribute) checking if each Order object’s orderNum matches the orderNum passed in as the method’s argument.

- If a matching orderNum is found, that Order object’s price should be updated to 0 (hint: price is private!) - If the orderNumber is not found, do nothing.

public class Order {
  
   private int orderNum;
   private int price;
  
   public Order(int orderNum, int price)
   {
       this.orderNum = orderNum;
       this.price = price;
   }
   public int getOrderNum()
   {
       return orderNum;
   }
   public void setOrderNum(int orderNum)
   {
       this.orderNum = orderNum;
   }
   public int getPrice()
   {
       return price;
   }
   public void setPrice(int price)
   {
       this.price = price;
   }
   public void print()
   {
       System.out.print("Order Number: " + orderNum);
       System.out.println(" Price: " + price);
   }

}

import java.util.ArrayList;
import java.util.Scanner;
import java.util.Random;

public class Store {
   private ArrayList<Order> orders = new ArrayList<Order>();


   public ArrayList<Order> getOrders()
   {
       return orders;
   }
  
   /*
   * Generates five Order objects, each with a hard-coded orderNum and price
   * and adds them to the Store's ArrayList
   */
   public void generateFiveOrders()
   {
       int numOrders = 5;
       //loop for each of the 5 orders
      
       int orderNum = 100;
       int price = 50;
      
       for(int i =0; i< numOrders; i++)
       {  
           Order o = new Order(orderNum + i,price); //each orderNum +1
           orders.add(o);
          
           price = price+10; //each order's price increments by 10
       }
   }
  
       /*
   * Complete the refundOrder method below so that it:
   *
   * - Accepts an int orderNum as its parameter //already implemented
   * - Searches through the ArrayList of Orders in the Store class
   * checking if each Order object's orderNum
   * matches the orderNum passed into the method.
   * - If an Order object with the specified order number is found,
   * - Set that Order object's price to 0 (note: price is a private int!)
   */
   public void refundOrder(int orderNum)
   {
   //YOUR CODE HERE
   }
}

In: Computer Science

4- Frank sold two lots for $62,000. If one lot sold for $48,000 more than the...

4- Frank sold two lots for $62,000. If one lot sold for $48,000 more than the other what was the price of each lot? Label with $ and round to the nearest dollar. Remember, all numbers > 999 must use comma(s).


Lot 1


Lot 2


5- Peggy paid her $85.00 electric bill with fives and tens. If there were 12 bills, how many were there of each denomination?


five dollar bills


ten dollar bills

6- Tickets for a football game cost $1.25 for students and $2.50 for others. If 10,000 tickets were sold and $22,500 received how many of each kind of ticket was sold?

student tickets


other tickets

7- Connoisseur Coffee Co. blends coffee costing $4.04 per pound with coffee costing $1.80 per pound to produce a brand costing $2.60 per pound. If a total of 140 pounds is blended, how many pounds of each were used?

pounds at $4.04


pounds at $1.80

8- Alice earned three times as much in commissions as Jerry but only ½ as much as Tom. If the total commissions for all three were $4,200, how much did each earn? Label with $ and round to the nearest dollar.

Alice's commission
Tom's commission
Jerry's commission

9- An airline offered a plan whereby the wife’s fare was 2/3 that of the husband, and a child’s fare was ½ of the father’s fare. The total fare for a married couple with three children was $304. Find the fare of each family member. Label with $ and round to the nearest dollar.


wife's fare
husband's fare
each child's fare


In: Statistics and Probability

Assume the that over the past couple of years your investment into a stock that pays...

Assume the that over the past couple of years your investment into a stock that pays no dividends was as follows:

Year Starting price Shares bought/sold
2010 49.8 50 bought
2011 55.7 100 bought
2012 50.7 150 sold

What is your dollar-weighted annual return for over this period for this investment?

Enter answer in percents, to two decimal places.

Bonus exploratory question: how does this compare to the average annual return, or the geometric average annual return?

In: Finance

Suppose that Larrys annual deductible for his health insurance plan is $10,000. His coinsurance rate is...

Suppose that Larrys annual deductible for his health insurance plan is $10,000. His coinsurance rate is 25%. The price of healthcare is $100 per visit, and Luke goes on 200 visits per year (after losing his hand, he’s REALLY sickly). Answer the following questions:


How much does Luke spend out-of-pocket on healthcare?


If Luke’s health insurance policy has a maximum out-of-pocket of $15,000, will this policy affect him? WHY or WHY NOT.


In: Economics