Questions
B. Write a program Median.java to read each file whose name is specified in the command-line...

B. Write a program Median.java to read each file whose name is specified in the command-line arguments. That is, for each command-line argument, open it as a file and read it.

The file contents are zero or more lines each containing a list of comma-separated integers, such as 1,2,3,4 or 99,120,33. You should parse each of these integers and save them in an ArrayList (if you prefer you may use an array, but an ArrayList is likely to be easier for this assignment).

Once you have filled your array list with all the integers in the line, you must compute the median value, that is, the integer for which half the integers in the line are above it, and half are below it. There are two subtleties that you should handle correctly:

- each integer may appear more than once: in 1,1,2,2,3, the median is 2

- with an even number of integers, the median may be the average of two of the integers: in 1,2,3,4, the median is 2.5

You must implement and use a method whose header is one of
private static double computeMedian(java.util.ArrayList<Integer> numbers)
or
private static double computeMedian(Integer[] numbers)
or
private static double computeMedian(int[] numbers)

to compute and return the median of all the numbers.

An algorithm to compute the median is as follows:

- for each number in the ArrayList (or array), compare it to all the numbers in the array, computing how many are above it, how many are below it, and how many are the same -- at least one (itself) should be the same.

- then if (the number below plus the number equal are greater than the number above) AND (the number below is less than the number equal plus the number above) then this number is the median.

For example, in 1,1,2,2,3:

- for the number 1, there are 0 numbers below, 2 numbers that are equal, and 3 numbers above, so 1 is not the median.

- for the number 2, there are 2 numbers below, 2 numbers that are equal, and 1 numbers above, so 2 is the median.

- for the number 3, there are 4 numbers below, 1 number that is equal, and 0 numbers above, so 3 is not the median.

On the other hand, if (the number below plus the number equal is the same as the number above) OR (the number below is the same as the number equal plus the number above) then this is one of two numbers, the average of which is the median.

For example, in 1,2,3,4,5,2, for the number 2, there is one number below and two numbers equal, which is the same as the three number above. For the number 3, there is one number equal and two numbers above, which is the same as the three numbers below. So in this case the median is the average of 2 and 3: mathematically, (2 + 3) / 2 = 2.5 (remember the division must be done using doubles, otherwise the result will be truncated).

To correctly implement this part of the computation, you need to have one or more variables declared outside the main loop, to keep track of whether you have already seen one of the two numbers whose average is the mean. In the example above, once you see 3 (after seeing 2), you should be able to immediately return the median 2.5. Be careful -- if you see another 2 (before seeing the 3), as in processing 2,2,1,3,5,4, you must continue your search past the second 2.

In: Computer Science

Please fulfill the requirements. Thank you Objectives: Perform C++ string object manipulation Understand how to manipulate...

Please fulfill the requirements. Thank you

Objectives:

  • Perform C++ string object manipulation
  • Understand how to manipulate data using arrays
  • Handle input errors and invalid values
  • Design and create a well-structured program using C++ basic programming constructs

Description:

Write a menu-driven program that provides the following options:

  1. Show All
  2. Spend
  3. Search expenses containing this string
  4. Search expenses with greater than or equal to this amount
  5. Exit

It allows the user to select a menu option to display all expenses, add new entry, search for a substring and find the list of entries greater a given amount.

Requirements:

  1. The program must produce similar output as example below. The output should be formatted nicely as given.
  2. The program must use array of structs
  3. The program must not use global variables. In another words, it must use local variables and pass-by-value or pass-by-reference parameters.
  4. The program must define the maximum number of entries such as 100 and keeps track of the actual count of the current number of expenses entered by the user
  5. You should not use data file to save or read from. All operations should be done through the use of arrays and array indices.
  6. You must write at least 2 functions.
  7. Do not use namespace std

Required error handling:

The program MUST perform the following checks:

  1. Check for invalid amount (negative or 0 number)
  2. Description cannot be empty.
  3. Search is case-insensitive (ignore case, but the user may type in any case).

Sample run:

D:\>TrackExpensesUsingArray.exe

Welcome to my expense tracker.

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 1

There is no expense entry available.

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 2

Please enter the description for the expense: Monthly telephone and Internet services

Please enter the amount: 45.25

AMOUNT(45.25) DESC(Monthly telephone and Internet services)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 2

Please enter the description for the expense: Monthly electric, water and gas

Please enter the amount: 200.20

AMOUNT(200.2) DESC(Monthly electric, water and gas)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 2

Please enter the description for the expense: Rent

Please enter the amount: 1200

AMOUNT(1200) DESC(Rent)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 2

Please enter the description for the expense: Netflix membership

Please enter the amount: 12.90

AMOUNT(12.9) DESC(Netflix membership)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 2

Please enter the description for the expense: Amazon membership

Please enter the amount: 99

AMOUNT(99) DESC(Amazon membership)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 2

Please enter the description for the expense: Monthly gym membership

Please enter the amount: 50

AMOUNT(50) DESC(Monthly gym membership)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 1

Expenses:

AMOUNT(45.25) DESC(Monthly telephone and Internet services)

AMOUNT(200.2) DESC(Monthly electric, water and gas)

AMOUNT(1200) DESC(Rent)

AMOUNT(12.9) DESC(Netflix membership)

AMOUNT(99) DESC(Amazon membership)

AMOUNT(50) DESC(Monthly gym membership)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 3

Please enter the search string: membership

AMOUNT(12.9) DESC(Netflix membership)

AMOUNT(99) DESC(Amazon membership)

AMOUNT(50) DESC(Monthly gym membership)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 3

Please enter the search string: MEMBERSHIP

AMOUNT(12.9) DESC(Netflix membership)

AMOUNT(99) DESC(Amazon membership)

AMOUNT(50) DESC(Monthly gym membership)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 4

Please enter the amount: 50

AMOUNT(200.2) DESC(Monthly electric, water and gas)

AMOUNT(1200) DESC(Rent)

AMOUNT(99) DESC(Amazon membership)

AMOUNT(50) DESC(Monthly gym membership)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 4

Please enter the amount: 200

AMOUNT(200.2) DESC(Monthly electric, water and gas)

AMOUNT(1200) DESC(Rent)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 4

Please enter the amount: 1000

AMOUNT(1200) DESC(Rent)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 2

Please enter the description for the expense: Home repair and improvement

Please enter the amount: -1

Invalid amount. Amount cannot be negative or string. Please try it again.

Please enter the amount: -100

Invalid amount. Amount cannot be negative or string. Please try it again.

Please enter the amount: -1000

Invalid amount. Amount cannot be negative or string. Please try it again.

Please enter the amount: 175.75

AMOUNT(175.75) DESC(Home repair and improvement)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 1

Expenses:

AMOUNT(45.25) DESC(Monthly telephone and Internet services)

AMOUNT(200.2) DESC(Monthly electric, water and gas)

AMOUNT(1200) DESC(Rent)

AMOUNT(12.9) DESC(Netflix membership)

AMOUNT(99) DESC(Amazon membership)

AMOUNT(50) DESC(Monthly gym membership)

AMOUNT(175.75) DESC(Home repair and improvement)

Expense Tracking Menu:

1. show all

2. spend

3. search expenses containing this string

4. search expenses with greater than or equal to this amount

5. exit

Enter your option: 5

D:\>

In: Computer Science

A woman can read the large print in a newspaper only when it is at a...

A woman can read the large print in a newspaper only when it is at a distance of 58 cm or more from her eyes. (a) Is she nearsighted (myopic) or farsighted (hyperopic), and what kind of lens is used in her glasses to correct her eyesight? (b) What should be the refractive power (in diopters) of her glasses (worn 2.3 cm from the eyes), so she can read the newspaper at a distance of 29 cm from the eyes?

In: Physics

Why is pricing an extremely important component of marketing? List 3 aspects of pricing that make...

Why is pricing an extremely important component of marketing? List 3 aspects of pricing that make it important to marketing, to the organization, and to its customers. Think of things that are unique to the pricing variable compared to the other three marketing variables of product, promotion, and distribution.

In: Economics

Describe a current problem facing your department, organization, or industry that would indicate the need for...

Describe a current problem facing your department, organization, or industry that would indicate the need for a simulation model. How best would this problem be solved by simulation versus the other modeling techniques covered in the course? Support your response with rationale from the readings.

In: Operations Management

Get information from the user Calculate Phone Line Charge Military Discount Display Phone Line Charge and...

Get information from the user Calculate Phone Line Charge Military Discount Display Phone Line Charge and Military Discount !!!!!

The user will need to input • Number of phone lines • Data plan chosen (U, M or L) U for Unlimited Data M for Moderate Data L for Limited Data • Military discount (Y or N) You can see examples of how to prompt the user for this information in the sample output windows below. Please note the number of phone lines can be an int, but the data plan and military discount need to use the char data type in order to store a U, M, L, Y or N. 2. Calculations (all these calculated variables should be double data type) • Phone Line Charge Unlimited data - $45 per phone line Moderate data - $25 per phone line Limited data - $15 per phone line • Discount (10% off phone line charge): if customer is an active or retired member of the military • Subtotal: Phone Line Charge - Discount • Surcharge and Taxes: 15% of Subtotal • Total: Subtotal + Surcharge and Taxes

In: Computer Science

Explain how you would use your understanding of ONE of the major developmental theories to deal...

Explain how you would use your understanding of ONE of the major developmental theories to deal with eachof the difficulties listed below:

a. Your infant daughter puts everything in her mouth, including the dog's food. b. Youreight-year-old son is failing math; all he cares about is baseball.

c. Your two-year-old daughter refuses to wear the clothes you pick for her every morning, which makesgetting dressed a twenty-minute battle.

d. Your sixty-eight-year-old neighbor is chronically depressed and feels she has wasted her life.

e. Your 18-year-old daughter has decided not to go to college. Instead she’s moving to Colorado to becomea ski instructor.

f. Your 11-year-old son is the class bully.

In: Psychology

Human Resource Planning (HRP) represents a significant improvement on traditional Manpower Planning exercise. Discuss

Human Resource Planning (HRP) represents a significant improvement on traditional Manpower Planning exercise. Discuss

In: Operations Management

JD’s Firewood is a small locally owned supplier of firewood to consumers that use wood boilers...

  1. JD’s Firewood is a small locally owned supplier of firewood to consumers that use wood boilers to heat their homes. JD’s offers a variety of seasoned hardwood for sale by the cord with varying prices. In addition, he also sells coal by the ton to customers as a heat fuel. JD’s is interested in determining the breakeven point based on the following expenses: Rent, utilities, and insurance per month is $540.00. Salaries per week are $1,260.00. JD’s Firewood is open 5 days per week. Use two decimal points and round up or down accordingly.
    1. What is the breakeven point in dollars using the information presented below?
    2. What is the breakeven point per day of operation?
    3. Based on the data presented, how much of each product should JD have in stock each week to breakeven?

Item

Price

Cost

Annual Forecasted Sales (Units)

Seasoned Oak (per cord)

$120.00

$16.00

340

Seasoned Maple (per cord)

$125.00

$18.00

180

Mixed Softwoods (per cord)

$80.00

$12.00

420

Coal (per ton)

$120.00

$80.00

504

In: Operations Management

Servant Leadership - List one organizational situation when this style will be Inappropriate/destructive?

Servant Leadership - List one organizational situation when this style will be Inappropriate/destructive?

In: Operations Management

Imagine a worker for a large grocery in the meat department. An incident with the meat...

Imagine a worker for a large grocery in the meat department. An incident with the meat grinder has left the worker with significant lacerations on his hands and he is unable to return to work. What type of assistance might he expect from WSIB? What could his manager do to expedite his return to work?Imagine a worker for a large grocery in the meat department. An incident with the meat grinder has left the worker with significant lacerations on his hands and he is unable to return to work. What type of assistance might he expect from WSIB? What could his manager do to expedite his return to work?Imagine a worker for a large grocery in the meat department. An incident with the meat grinder has left the worker with significant lacerations on his hands and he is unable to return to work. What type of assistance might he expect from WSIB? What could his manager do to expedite his return to work?Imagine a worker for a large grocery in the meat department. An incident with the meat grinder has left the worker with significant lacerations on his hands and he is unable to return to work. What type of assistance might he expect from WSIB? What could his manager do to expedite his return to work?

400 words for the answer.

In: Operations Management

What must be true in Newton's second law if the object in question moves at a...

What must be true in Newton's second law if the object in question moves at a constant velocity? Similarly, what must be true in Newton's second law if the object accelerates? What are the customary rules for drawing a free body diagram? What is the value of drawing an a free body diagram? If 2 objects are in constant with each other. what does Newton's third law dictate should be evident when free body diagrams are drawn of the 2 objects?

In: Physics

When k=2 and the initial values of the mean vector are (2,8) and (8,1), perform k-means...

When k=2 and the initial values of the mean vector are (2,8) and (8,1), perform k-means clustering on the following input samples in the 2D feature space.
(Each iteration step, find the change of the sample vector.


Input sample set={(1,2),(2,3),(4,2),(7,10),(5,7),(9,7)}

In: Computer Science

Describe the last time that you or someone you saw conformed to the group around you/them....

Describe the last time that you or someone you saw conformed to the group around you/them. Determine how many of the factors that increase conformity that we discussed in Asch's line study were present in the situation

In: Psychology

Question 1: IT Governance [50 marks] According to a variety of studies, IT governance is usually...

Question 1: IT Governance [50 marks]

According to a variety of studies, IT governance is usually implemented so as to ensure that IT operations and investments deliver more value to the business.

a) Discuss the activities that are required to setup IT governance in an organization. [25 marks]

b) With the aid of examples, discuss the factors that could affect IT governance. [25 marks]

Question 2: Strategic Management of IT [50 marks]

The strategic management of IT can be achieved through the use of various resources.

a) With the aid of examples, discuss the role played by policies and procedures in the strategic management of IT. [25 marks]

b) Propose and discuss the aspects that should be considered during the drafting of an Information Security policy document [25 marks]

Question 3: Risk Management [50 marks]

Risk management was identified in the NamCode as being an important activity during governance.

a) Outline how you would develop a risk management program in IT [25 marks]

b) Critically evaluate the strengths and weakness of the various risk analysis methods in IT. [25 marks]

Question 4: Business Continuity planning [50 marks]

Business Continuity planning involves the creation and validation of a logistical plan that outlines how an organization will recover from a disaster or extended disruption of operations.

a) Identify and discuss the phases of a Business Continuity life cycle. [25 marks]

b) With the aid of examples, discuss the various issues that could indicate that a Disaster Recovery Plan is not in order. [25 marks].

In: Computer Science