Skip to content

Latest commit

 

History

History

Problem_07

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Exercise 1:

Write a program AboveAverage.java that takes n integers from command-line, and prints the fraction of values that are strictly above the average value.

(Interesting fact: 90% of incoming college students rate themselves as above average).

Exercise 2:

We'll say that an element in an array is "alone" if there are values before and after it, and those values are different from it. Write a program NotAlone.java that read n numbers from command line, store them in an array and return a version of the array where every instance of the given value which is alone is replaced by whichever value to its left or right is larger.

e.g.

[1, 2, 3] --> [1, 3, 3]

[1, 2, 3, 2, 5, 2] --> [1, 3, 3, 5, 5, 2]

[3, 4] --> [3, 4]