Reference no: EM132399557
CSE 1321L: Programming and Problem Solving Lab
Lab - Single-Dimensional Arrays
Exercise #1: Design and implement a program (name it AssignGrades) that stores and processes numeric scores for a class. The program prompts the users to enter the class size (number of students) to create a single-dimensional array of that size to store the scores. The program prompts the user to enter a valid integer score (between 0 and 100) for each student. The program validates entered scores, rejects invalid scores, and stores only valid scores in the array.
The program defines method printGrades() that takes a signal-dimensional array of integer scores as a parameter and processes the scores to print letter grades based on the following scale:
Grade is A if score >= 90 and score <= 100
Grade is B if score >= 80 and score <= 89
Grade is C if score >= 70 and score <= 79
Grade is D if score >= 60 and score <= 69
Grade is F if score < 60
Exercise #2: Design and implement a program (name it CompareArrays) that compares the content of 2 single-dimensional arrays of the same size. The program prompts the users to enter the array size. Then prompts the user to initialize each array with integer values. The program defines method Compare() that takes two signal-dimensional arrays of type integer. The method compares the content of the arrays and returns true (Boolean type) if the arrays store same values in the same order. Otherwise, it returns false. The program main method calls method Compare()and prints the result from the method as shown below. Document your code and organized your output following these sample runs.
Exercise #3: Design and implement a program (name it ArrayMethods), that defines 4 methods as follows:
int arrayMax(int[] arr) returns the maximum value in the an array
int arrayMin(int[] arr) returns the minimum value in an array
void arraySquared(int[] arr) changes every value in the array to its square (value²)
void arrayReverse(int[] arr) reverses the array (for example: array storing 7 8 9 becomes 9 8 7 )
The program main method creates a single-dimensional array of length 5 elements and initialize it with random integers between 1 and 100. The program displays the original array, then calls each of the above methods and displays their results as shown below. Document your code and organized your output following these sample runs.
Attachment:- Single-Dimensional Arrays.rar