Attendance is worth 10 points.
(45 points) Team Problem 1:
For this program you need to submit the source code
(.java), including prolog.
The algorithm design to solve the problem is as follows:
function purpose: return second largest number of the array 1.1 declare two integer variables smallest and largest, initialized with the first element of the array 1.2 loop through the array using loop index i 1.2.1 if the current element is greater than largest, set largest to the current element 1.2.2 if the current element is less than smallet, set smallest to the current element 2. declare an integer variable, called sl, set its value to the smallest element of the list 2.1 loop through the array using loop index i 2.1.1 if current element is strictly greater than sl AND current element is strictly smaller than the largest element, then set sl to current element 3. return sl
You are given the skeleton of the program and you cannot change anything in the main() function
import java.util.Scanner; public class sl { // start here with function definition // DO NOT CHANGE ANYTHING IN THE MAIN FUNCTION public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.print("Please enter 10 integers: "); int[] myRefArray = new int[10]; for(int i=0;i<10;i++) myRefArray[i] = s.nextInt(); int sl = secondLargest(myRefArray); System.out.print("The second largest element in the array is: " + sl); } }
(45 points)Individual Problem 1:
For this program you need to submit the source code
(.java), including prolog and comments.
Write a program that reads five integers and displays them in the reverse order they were read.
Here are some sample runs:
Sample run 1: Enter 5 integers: 6 7 8 9 0 The integers in reverse order are: 0 9 8 7 6 Sample run 2: Enter 5 integers: -1 2 -3 4 -5 The integers in reverse order are: -5 4 -3 2 -1
To successfully complete this lab you should: