*****************PLEASE GIVE THE CODE IN RACKET PROGRAMMING ONLY AND MAKE SURE THE CODE RUNS ON WESCHEME IDE***************
Write a recursive Racket function "keep-short-rec" that takes an integer and a list of strings as parameters and evaluates to a list of strings. The resulting list should be all of the strings from the original list, maintaining their relative order, whose string length is less than the integer parameter. For example, (keep-short-rec 3 '("abc" "ab" "a")) should evaluate to '("ab" "a") because these are the only strings shorter than 3. Your solution must be recursive. Note: (string-length s) evaluates to the length of string s
In: Computer Science
(1) Prompt the user to enter four numbers, each corresponding to
a person's weight in pounds. Store all weights in a list. Output
the list. (2 pts)
Ex:
Enter weight 1: 236 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3]
(2) Output the average of the list's elements. (1 pt)
(3) Output the max list element. (1 pt)
Ex:
Enter weight 1: 236 Enter weight 2: 89.5 Enter weight 3: 176.0 Enter weight 4: 166.3 Weights: [236.0, 89.5, 176.0, 166.3] Average weight: 166.95 Max weight: 236.0
(4) Prompt the user for a number between 1 and 4. Output the
weight at the user specified location and the corresponding value
in kilograms. 1 kilogram is equal to 2.2 pounds. (3 pts)
Ex:
Enter a list index (1 - 4): 3 Weight in pounds: 176.0 Weight in kilograms: 80.0
(5) Sort the list's elements from least heavy to heaviest
weight. (2 pts)
Ex:
Sorted list: [89.5, 166.3, 176.0, 236.0]
This is what I have so far:
# FIXME (1): Prompt for four weights. Add all weights to a list.
Output list.
weights = []
for i in range(4):
w = float(input("Enter weight "+str(i+1)+":"))
weights.append(w)
print("\nWeights:",weights)
# FIXME (2): Output average of weights.
avg = sum(weights) / float(len(weights))
print("Average weight:",avg)
# FIXME (3): Output max weight from list.
print("Max weight:",max(weights))
# FIXME (4): Prompt the user for a list index and output that
weight in pounds and kilograms.
index = int(input("\nEnter a list index location (1 - 4):
\n"))
print("Weight in pounds:",weights[index-1])
print("Weight in Kilograms:",weights[index-1]/2.2)
# FIXME (5): Sort the list and output it.
weights.sort()
print("\nSorted list:",weights)
Your output starts with
Enter weight 1:
Weights: [236.0]
Enter weight 2:
Weights: [236.0, 89.5].
Enter weight 3:
Weights: [236.0, 89.5, 176.0]
Enter weigt 4:
Weights: [236.0, 89.5, 176.0, 166.3]
Expected output starts with
Enter weight 1:
Enter weight 2:
Enter weight 3:
Enter weight 4:
Weights: [236.0, 89.5, 176.0, 166.3]
How do I fix this!?
In: Computer Science
I need some asistance understanding of what to do for this problem in javascript:
* Problem 9 - find the largest number in the list of arguments
*
* Allow any number of arguments to be passed to the function. Allow both
* String and Number arguments to be passed, but throw an error if any other
* type is passed to the function (e.g., Boolean, Date, etc.). If the list
* is empty (nothing passed to the function), return null. Otherwise, return
* the largest value that was passed to the function as an argument:
*
* findLargest(1, 2, '3', '4', 5) should return 5
* findLargest('5') should also return 5
* findLargest(5, 3, 2, 1) should also return 5
******************************************************************************/
function findLargest() {
// Your code here...
}
here are the test cases:
const { findLargest } = require('./solutions');
describe('Problem 9 - findLargest', function() {
test('should find the largest number in a list', function() {
let largest = findLargest(1, 2, 3);
expect(largest).toBe(3);
});
test('should find the largest number in a list of 1', function() {
const largest = findLargest(1);
expect(largest).toBe(1);
});
test('should find the largest number in a long list', function() {
// https://github.com/gromgit/jstips-xe/blob/master/tips/33.md
const list = Array.apply(null, { length: 5000 }).map(Function.call, Number);
const largest = findLargest.apply(null, list);
expect(largest).toBe(4999);
});
test('should work with negative numbers', function() {
const largest = findLargest(1, 2, 3, -1, -2, -3);
expect(largest).toBe(3);
});
test('should work with strings that are numbers', function() {
const largest = findLargest('1', '2', '3');
expect(largest).toBe(3);
});
test('should work with decimals', function() {
const largest = findLargest(0.01, 0.001);
expect(largest).toBe(0.01);
});
test('should throw if a Boolean is included in the list', function() {
function shouldThrow() {
findLargest(1, true, 3);
}
expect(shouldThrow).toThrow();
});
test('should throw if an Object is included in the list', function() {
function shouldThrow() {
findLargest(1, console, 3);
}
expect(shouldThrow).toThrow();
});
test('should throw if a null is included in the list', function() {
function shouldThrow() {
findLargest(1, null, 3);
}
expect(shouldThrow).toThrow();
});
test('should throw if a undefined is included in the list', function() {
function shouldThrow() {
findLargest(1, undefined, 3);
}
expect(shouldThrow).toThrow();
});
test('should return null if the list is empty', function() {
const largest = findLargest();
expect(largest).toBe(null);
});
});
In: Computer Science
In: Accounting
1. Two samples of a low hardness steel were tested using a Rockwell C hardness tester and the Rockwell B scale at the same lab on the same day. The difference between the average hardness of the two samples was 0.5 Rockwell C. Do you think there is a significant difference in the hardness? Justify your answer.
2. Two manufacturers produce a steel. Manufacturer B claims their steel is better than manufacturer A because their average Rockwell B hardness is 68.4 HRBW while that of manufacturer B is 60.5 HRBW. Do you think there is a significant difference in their hardness? Justify your answer. Hint: Use the specification!!
3. Find an important engineering failure that involves some of the topics discussed in MSE 350. Describe the failure, why it occurred, the damage (human, environmental, and economic) and the changes that could have been made in the design to avoid the failure. Was the failure caused by lack of engineering knowledge at the time, engineering error, or management/government error? Discuss!!
4.
For each of the following common items, identify what they are commonly made of, the material type (composite, metal, semiconductor, polymer <thermoplastic, thermoset or elastomer>, ceramic, glass. Describe why that material type is used. Include at least two references for your answers (websites are fine, but try and find good ones). If more than one material type is used in the items, include them all! Be careful to use proper engineering vocabulary when answering this question!
Abrasives for grinding metal
Automobiles
Integrated circuits
Airplanes
Bridges
Solar panels
Latex paint
Soda bottles
Polyvinylchloride (PVC) plumbing pipes
In: Mechanical Engineering
1. Post an example of Inferential Statistics.
2. Give an example of a Discrete Variable and an example of a
Continuous Variable. Do not use examples posted by other
students.
In: Statistics and Probability
Provide examples of each of the four types of scales. You must post original examples. You may not copy and paste from prior students' posts.
In: Statistics and Probability
In: Advanced Math
The average GPA at a college is 2.73 with a standard deviation of 0.8. Find the probability that 10 randomly selected students will have an average GPA greater than 2.37
In: Statistics and Probability
The probability that a person has 20-20 vision
is
0.13 The class is 40 students. What is the mean and the Standard
deviation of the number with 20-20 vision in the class.
In: Statistics and Probability