Explore BrainMass
Share

Second smallest number in the list

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

Write a Ruby program with the following specification:

Input: A list of numbers from the keyboard.
Output: The second smallest number in the list, along with its position in the list, with 1 being the position of the first number.

© BrainMass Inc. brainmass.com October 25, 2018, 6:25 am ad1c9bdddf
https://brainmass.com/computer-science/html-html5/second-smallest-number-in-the-list-459356

Solution Preview

Please save the following program in a file, say, number.rb . If you give less than 2 numbers as input, it won't output anything.

------------- Program text ------------
#!/usr/bin/ruby

numberList = Hash.new

#
# Read a list of numbers from the keyboard.
#
puts "Enter numbers one per line."

count = 1
$stdin.each_line ...

Solution Summary

Ruby program in the solution assumes that input contains at least two numbers. If you give less than two numbers as input, it will not output anything.

$2.19
See Also This Related BrainMass Solution

The following list identifies several potential cost drivers for a manufacturing company that makes eight products. The company uses a JIT production system so it stores finished product for a very limited time. The 8 products vary substantially in size from small (plastic casings for pens) to large (plastic casings for truck instrument panels).
? Number of setups
? Setup time
? Square feet
? Cubic feet
? Cubic feet weeks
For each situation described below (activity and related resource), identify the best cost driver from the list and briefly justify your choice.
1. To produce a product, production mechanics must set up machinery. It takes about the same time to set up for a production run regardless of the product being produced. What is the best cost driver for the setup activity?
2. Instead of the situation described in number 1, what driver should the company use for the setup activity if it takes longer to set up for complex products, such as the instrument panel casings, than for simple products, such as pen casings?
3. What driver should the company use for warehouse occupancy costs (depreciation and insurance)?
The company uses the warehouse to store finished product.
4. What driver should the company use for the warehouse occupancy costs if it did not use a JIT system (that is, the company maintains inventories), and upon inspection, one of the products had a thick layer of dust on it?

3-34 Cost Function for Expedia
Expedia provides travel services on the Internet. 2002 was an important year for Expedia as it
reported positive operating income after three years of operating losses. In the first quarter of 2001, Expedia reported an operating loss of $19 million on sales revenue of $57 million. In the first quarter of 2002, sales revenue had more than doubled to $116 million, and Expedia had operating income of $18 million. Assume that fixed costs were the same in 2002 as in 2001.
1. Compute the operating expenses for Expedia in the first quarter of 2001. In the first quarter of 2002.
2. Determine the cost function for Expedia, that is, the total fixed cost and the variable cost as a percentage of sales revenue. Use the same form as equation (1) on page 100.
3. Explain how Expedia's operating income could increase by $37 million with an increase in sales
of $59 million, while it had an operating loss of $19 million on its $57 million of sales in the first quarter of 2001.

2-27,
2-29,
3-33,
3-34
Question 3-38, Mixed Cost, Choosing Cost Drivers, and High-Low and Visual-Fit Methods, on pp. 121 & 122
3-45

Please place solutions in excel format

2-27 Identifying Cost Drivers
The following list identifies several potential cost drivers for a manufacturing company that makes eight products. The company uses a JIT production system so it stores finished product for a very limited time. The 8 products vary substantially in size from small (plastic casings for pens) to large (plastic casings for truck instrument panels).
? Number of setups
? Setup time
? Square feet
? Cubic feet
? Cubic feet weeks
For each situation described below (activity and related resource), identify the best cost driver from the list and briefly justify your choice.
1. To produce a product, production mechanics must set up machinery. It takes about the same time to set up for a production run regardless of the product being produced. What is the best cost driver for the setup activity?
2. Instead of the situation described in number 1, what driver should the company use for the setup activity if it takes longer to set up for complex products, such as the instrument panel casings, than for simple products, such as pen casings?
3. What driver should the company use for warehouse occupancy costs (depreciation and insurance)?
The company uses the warehouse to store finished product.
4. What driver should the company use for the warehouse occupancy costs if it did not use a JIT system (that is, the company maintains inventories), and upon inspection, one of the products had a thick layer of dust on it?

3-34 Cost Function for Expedia
Expedia provides travel services on the Internet. 2002 was an important year for Expedia as it
reported positive operating income after three years of operating losses. In the first quarter of 2001, Expedia reported an operating loss of $19 million on sales revenue of $57 million. In the first quarter of 2002, sales revenue had more than doubled to $116 million, and Expedia had operating income of $18 million. Assume that fixed costs were the same in 2002 as in 2001.
1. Compute the operating expenses for Expedia in the first quarter of 2001. In the first quarter of 2002.
2. Determine the cost function for Expedia, that is, the total fixed cost and the variable cost as a percentage of sales revenue. Use the same form as equation (1) on page 100.
3. Explain how Expedia's operating income could increase by $37 million with an increase in sales
of $59 million, while it had an operating loss of $19 million on its $57 million of sales in the first quarter of 2001.

View Full Posting Details