[BASIC JAVA] **Answer with basic jave please! If picture is available please sho
ID: 666802 • Letter: #
Question
[BASIC JAVA]
**Answer with basic jave please! If picture is available please show the output.
1. Write a complete Java method that takes an array of integers called numbers. Use a for loop to find the minimum value in the array. The method returns that value as an integer.
2. Write a complete Java method that uses two parameters to determine and return a letter grade. The parameters are an integer called myAvg and a boolean called participation. The return value is a String, the letter grade. The letter grade is determined as follows. If participation is true, A is an average greater than 89; B is greater than 79; C is greater than 69; otherwise the grade is a D. If participation is false, B is an average greater than greater than 89; C is greater than 79; otherwise the grade is a D.
3. Write a complete Java method that returns an integer. The method declares a Scanner object, then prompts the user for a series of integers in a while loop. If the user enters an integer (not a string, double, etc) then read each value entered and keep a running total (a sum). Make sure to validate that the user enters only integers. Include a sentinel value (-1) to allow the user to indicate when they are done. The method returns the total.
4. Write a complete Java method that takes two parameters: a 2-dimensional array of Strings called nameTable and a String called nameTofind. The method returns a boolean. Your method should traverse (search) the 2-dimensional array of names to check for a match with nameToFind. If the nameTofind String is found in the array return true, otherwise return false.
(NOTE: to receive full credit, you must use a nested for loop to find nameToFind.)
5. Write a complete Java method that takes a String called fileName as a parameter (the name of the input file); reads the input text file; and returns an ArrayList of Strings. The ArrayList contains a String element for each line in the text file. Make sure to handle the Exception that might be thrown.
Explanation / Answer
1) Java program to find smallest number in an array
public class FindSmallest {
public static void main(String[] args) {
int[] numbers = {44,55,66,77,88,99};
int smallest = Integer.MAX_VALUE;
for(int i =0;i<numbers.length;i++) {
if(smallest > numbers[i]) {
smallest = numbers[i];
}
}
System.out.println("Smallest number in array is : " +smallest);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.