subject

Create a HighestGrade application that prompts the user for five grades between 0 and 100 points and stores the grades in an ArrayList. HighestGrade then traverses the grades to determine the highest grade and then
displays the grade along with an appropriate message.

For HighestGrade, you need to use an ArrayList. You do not need to declare any Integer elements because you do not need to use a .get since you don’t need to find the index position of the grades. Use two loops. The first loop will ask the user to enter a grade. The second loop will determine the highest grade

import java. util. ArrayList;

public class DataArrayList {

public static void main(String[] args) {
ArrayList numbers = new ArrayList ();
Integer element, element1, element2;
int sum = 0;

numbers. add(new Integer(5));
numbers. add(new Integer(2));

/* compare values */
element1 = numbers. get(0);
element2 = numbers. get(1);
if (element1.compareTo(element2) == 0) {
System. out. println("The elements have the same value.");
} else if (element1.compareTo(element2) < 0) {
System. out. println("element1 value is less than element2.");
} else {
System. out. println("element1 value is greater than element2.");
}

/* sum values */
for (Integer num : numbers) {
element = num;
sum += element. intValue(); //use int value for sum
}
System. out. println("Sum of the elements is: " + sum);
}
}

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:40
Write a program that defines symbolic names for several string literals (chars between quotes). * use each symbolic name in a variable definition. * use of symbolic to compose the assembly code instruction set can perform vara = (vara - varb) + (varc - vard); ensure that variable is in unsigned integer data type. * you should also further enhance your symbolic logic block to to perform expression by introducing addition substitution rule. vara = (vara+varb) - (varc+vard). required: debug the disassembly code and note down the address and memory information.
Answers: 3
question
Computers and Technology, 23.06.2019 09:50
Allison and her group have completed the data entry for their spreadsheet project. they are in the process of formatting the data to make it easier to read and understand. the title is located in cell a5. the group has decided to merge cells a3: a7 to attempt to center the title over the data. after the merge, allison points out that it is not centered and looks bad. where would the title appear if allison unmerged the cells in an attempt to fix the title problem?
Answers: 2
question
Computers and Technology, 23.06.2019 11:00
How should you specify box sizes on a web page if you want the boxes to vary according to the font size of the text they contain? a. in pixels b. in inches c. as percentages d. in em units
Answers: 2
question
Computers and Technology, 24.06.2019 13:50
Write a program that performs a simple n-body simulation, called "jumping leprechauns." this simulation involves n leprechauns, numberd 1 to n. it maintains a gold value g_i for each leprechaun i, which begins with each leprechaun starting out with a million dollars worth of gold, that is, g_i = 1000000 for each i = 1,. in addition, the simulation also maintains, for each leprachaun,i, a place on the horizon, which is represented as a double-precision floating point number, x_i. in each iteration of the simulation, the simulation processes the leprachauns in order. processing a leprachaun i during its iteration begins by computing a new place on the horizon for i, which is determined by the assignment:
Answers: 3
You know the right answer?
Create a HighestGrade application that prompts the user for five grades between 0 and 100 points and...
Questions
question
Health, 19.05.2021 17:20
question
Computers and Technology, 19.05.2021 17:20
Questions on the website: 13722361