Question 1: Write a method called multiplicationTable, with return type void, and one parameter x of type int that prints the multiplication table from 1 to x (including x). Your output needs to be in...

Please answer these programming questions.


Question 1: Write a method called multiplicationTable, with return type void, and one parameter x of type int that prints the multiplication table from 1 to x (including x). Your output needs to be in a tabular format. Question 2: Assume you have a method with the following signature: public static boolean isPrime(int num) Further assume that this method is already written for you. You can just use it in your code. The function isPrime will return either True or False depending on if num is prime or not. Write a method named findPrimesInRange that accepts two integer parameters x and y, and displays all the prime numbers between x and y (inclusive). This methods need to use isPrime in prime number determination. Question 3: Write a method called MakeArrayRange. This method takes in two integers (X, Y) and returns a new integer array that contains all the values between X and Y, inclusive, inside of the array in order. If X is greater than Y, the returned array is empty. Question 4: Write a method named sumOfEvenValues that accepts a one-dimensional array of type integer, finds, and returns the sum of all even values in the array. Question 5: Write a method called mySearch, that has one int array parameter called arr, and one int parameter called key. The method returns true if the value of key exists in the arr, otherwise returns false. Question 6: Write a method named largestToBack that accepts an array of int values, finds the max value and swaps the max value and the last element of the array. Only the max and the last element can change places in the array. Hint: You will have to keep track of the index of the max value as you find the max value. After you have found the max value, you need to swap the max value and the last element using a temp variable. Question 7: Consider the following code snippet: int userInput = input.nextInt(); int score = 0; switch(userInput % 2) { case 0: score = userInput + 5; break; case 1: score = userInput * 5; break; } System.out.printf(“Score: %d”, score); a) What would the user have to enter to get an output of Score: 35? b)What would the user have to enter to get an output of Score: 65?
May 05, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here