1. Write a program that calls these two methods as described below a. A void method that prints following pattern (Pay attention to the space in between the characters) (Worth: 40 points) 1 12 123 123 4 123 4 5 b. A void method creates an integer array of size 12. The method then ask user to input these 12 numbers and store them in the array. Then print out all the numbers that are multiples of 3 and then print out all the numbers that are multiples of 4. (Worth: 60 points, 30 for each part) Example: Input a number (1/12): 3 Input a number (2/12): 5 Input a number (3/12): 7 Input a number (4/12): 8 Input a number (5/12): 2 Input a number (6/12): 3 Input a number (7/12): 10 Input a number (8/12): 6 Input a number (9/12): 2 Input a number (10/12): 7 Input a number (11/12): 12 Input a number (12/12): 9 The multiples of 3 are: 3, 3, 6, 12, 9 The multiples of 4 are: 8, 12
Q: Consider the following method: public static void arrayMystery(int[) a) { for (int i = 1; i <…
A: a[0] = 4 a[1] = 2 a[2] = -2 a[] = {4, 2, -2}
Q: Write the following methods in your class: 1. A method named duplicatesCount that takes an array of…
A: Q: As per bartleby policy, we can answer only one part per question. Request you to please post…
Q: Question 2 (a) Write a program to repeatedly read in integers (negative and positive) from the user…
A: Class methods are the methods which are called on the class itself, not on the specific object…
Q: A method int [] makeRandomArray(int size ,int a , int b) that makes and returns an array with…
A: hi there in the code as mentioned, above i have used all four methods int[] make randomArray(): To…
Q: Consider the following method:public static void mystery5(int[] nums) {for (int i = 0; i <…
A: A) {8} Here the number of element in array is 1. So the if condition would be false. Thus final…
Q: This is the question I am stuck on - In the exercises in Chapter 6, you created a class named…
A: The main objective of the program is to create three methods, called sortBySaleAmount,…
Q: 1. Write a program that calls a method that takes a character array as a parameter (you can…
A: PROGRAM: //Defining class public class CountVowels { //Defining main() public static void…
Q: Write a method that takes three inputs. The first input is a 2d array of integers, the second and…
A: Given : Write a method that takes three inputs. The first input is a 2d array of integers, the…
Q: In Java: Ask the user to enter the size of an array. It must be greater than 0. Write a method,…
A: Step 1 : Start Step 2 : Define the method inputValidation() which inputs the array size from the…
Q: Write a program in a class FlowerCounter that computes the cost of flowers sold at a flower stand.…
A: import java.util.Scanner; public class FlowerCounter { public static void main(String[] args) {…
Q: onsider the following method: Method Body: void insertinArray(int num, int index){ int i; if(index…
A: From the above question, this function requires to check if the array is sorted or not, up to the…
Q: Write a method (use any valid name) to accomplish the following task: To receive an integer array as…
A: Algorithm: Step-1: Start Step-2: Define a method with passing one parameter or argument, that is…
Q: In a program, firstly create an array with the size of 10 and prompt you enter to the numbers. Then…
A: Given: In a program, firstly create an array with the size of 10 and prompt you enter to the…
Q: Q3: Write a Java program that has the following methods: computeAverage () which takes an array of…
A: Average = total marks/ number of students If a students scores more than or equal to 35 then he/she…
Q: Create a class containing the main method. In the main method, create an integer array and…
A: length is the array field that holds length of the array
Q: Create a program whose Main() method declares an array of 10 integers. Call a method to…
A: #include <iostream>using namespace std; void fill(int arr[], int n){ int i=0;…
Q: Write a java program that have two methods: a. dotPattern () – A void method that prints this…
A: The required Java code: import java.util.Scanner;public class TriangleArray{public static void…
Q: Write (define) a public static method named countGreaterThan, that takes an array of int, and an int…
A: public class Main{ public static int countGreaterThan(int arr[], int value) { int count…
Q: Write a method that receives an array to determine how many scores are above or equal to the…
A: Program approach: import Scanner class for input. Create a class with the name AboveEqualAvgScore.…
Q: 1. Write a method to search for a given value in a 2D array. Write a complete program to use this…
A: Program Screenshot: Output Screenshot: Program: import java.util.*;public class Main{ public…
Q: Need help writing the following method: getRegisteredStudents() – returns an array of type…
A: the answer is given below:-
Q: This is the code that I am unsure where to fully start -
A: Approach For loop is used to iterate over Purchase array length. In the loop, the user is asked to…
Q: Given the following multidimensional array, complete the method below so that it will access the…
A: The missing code is given below along with the explanation:
Q: Write a program that calls these two methods as described below printPattern (int a) – A void method…
A: NOTE: Since the language has not been mentioned I have used Python for this question. Also if you…
Q: 1)Write a method that takes an array of ints and returns the sum of all numbers that are even. For…
A: NOTE : Answering only the first question as per the policy. Since programming language is not…
Q: Problem 5: (Practice Problem: Due Tuesday 4/21/2020) Write a method, getFoodCost which takes three…
A: Program code: //import the required packageimport java.util.*; //define the class public class Main…
Q: Create a program whose Main() method declares an array of 10 integers. Call a method to…
A: Here I have created a function named fillArray(). In this function, I have taken input from the user…
Q: Write a program called Range_array.java that has a method with one integer array and two integers…
A: import java.util.*;public class Main{ public static int [] delete_range(int [] arr,int start,int…
Q: in java Write a class phone that stores Name (String) and number of friends (String), Provide…
A: Note : This program is case sensitive i did not ignore the case while searching the names //Java…
Q: 1. Write a method that returns an int array using user's inputs from the console window. The method…
A: Java Code :- package homework; import java.util.Arrays; import java.util.Scanner; public class HW8…
Q: Problem #1: Write a method that takes an array of integers and shifts it to the right by one…
A: Indentation is used to make the code readable to other users because it makes the code easier to…
Q: 2.write a method that receives an array of numbers and a key and returns true if the key exists in…
A: We need to write a method that receives an array of numbers and a key. And returns true if the key…
Q: Write a method named minimum value, which returns the smallest value in an array that is passed (in)…
A: // Recursive Java program to find minimum elementimport java.util.*; class RMEA { // method…
Q: c) Write a public static method getFirstD() with the following: o The method accepts 2 arguments:…
A: The static method is given below which satisfies all the conditions given in the problem. as no…
Q: Write (define) a public static method named getInRange, that takes three arguments. The first…
A: public class Main{ public static void main(String[] args) { int[] myArray = {1, 22, 333, 400,…
Q: Write a method that accepts an array of integers as a parameter and returns a reference to an array…
A: First count the number of even numbers Then create the array with this count size Then, assign the…
Q: A void method creates an integer array of size 12. The method then ask user to input these 12…
A: Note: Here you didn't mention any programming language so we are creating the program in the C++…
Q: Create a method that will take client's integer array and sort the elements of the client's array in…
A: public static void sort(int array[])
Q: In a program, write a method that accepts two arguments: an array of integers and a number n. The…
A: We have to write a method that accepts an array of integers and number n as parameters and then…
Q: The following block of code is intending to display the values that store in array. public static…
A: Hi, since there are multiple questions in this post, as per our policy, I'll answer the first…
Q: // Among indexes first...last, return index of the target. // If target is not present then return…
A: Task : Complete the given method to a working java code. I have completed the given method using a…
Q: Write a method that returns the range of an array of integers. The range is the difference between…
A: Please find the answer below :
Q: Create a Java program with a method that searches an integer array for a specified integer value…
A: Programming instructions: First, create an array and initialize it. Then, take input from the user…
Q: In ArrayUtility class, create a public static method equals that receives two arrays of int's and…
A: class ArrayUtility: // class ArrayUtilitypublic class ArrayUtility{/// function toString return as…
Q: b. In the main method, The program reads from the user the number of branches in the company. The…
A: Step 1 : Start Step 2 : Create a method getBranchSalariesSum to compute the Maximum salary given by…
Q: Needs to br written in java: printPattern (int a) – A void method which takes user input as a…
A: import java.util.*;class Test169 { public static void main(String args[]) { Scanner sc = new…
Q: Write a program to accomplish the following tasks:- a) Write a method to print the ArrayList in the…
A: Write a program to accomplish the following tasks:- a) Write a method to print the ArrayList in the…
Q: 1. Write a program that calls these two methods as described below printPattern ()-A void method…
A: Java code: import java.util.Arrays;import java.util.Scanner;public class Main{ public static void…
Q: Write a Java program (BasicStatistics.java) that prompts the user to enter 10 numbers as double…
A: Java code to calculate the mean and standard deviation. Comment are add in the code only. Here…
Q: 2. Write a method that takes a rectangular two-dimensional array of type int and returns a valu of…
A: Code public class Main{ public static void main (String[]args) { int a[][] = { {8, -3,…
write in java please
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images
- Write a program that calls these two methods as described below printPattern (int a) – A void method which takes user input as a parameter and generates 5 multiples of the input and stores the multiples in the array and finally prints the numbers in the following pattern (See expected output)Note: Use the array to print the numbers Enter a number : 4 Multiples of 4 are stored in an array – [4,8,12,16,20] 4 4 8 4 8 12 4 8 12 16 4 8 12 16 20 printLarge (int a, int b) – A method which takes user input as a parameter and returns all the numbers between the two numbers in an array to the main method. Note: Print the array from the main method Enter two numbers : 5,10 The numbers between 5 and 10 are - 6,7,8,91. write a static method that receive as parameter an array of type student and print the names of all students excepted to graduate. The student is expected to graduate if he/she in year 4 and GPA >2. 2. Write a java program that: a. Asks the user to enter the number of the Student, then the data of each Student and store then inside an array of type Student. b. Ask the user to read a value d of type double then displays the name of all the Student who have GPA greater than the value d. c. Call the above method and print the name of student who excepted to graduate.Define an array to be a 121 array if all elements are either 1 or 2 and it begins with one or more 1s followed by a one or more 2s and then ends with the same number of 1s that it begins with. Write a method named is121Array that returns 1 if its array argument is a 121 array, otherwise, it returns 0. There is one additional requirement. You should return 0 as soon as it is known that the array is not a 121 array; continuing to analyze the array would be a waste of CPU cycles. If you are programming in Java or C#, the function signature isint is121Array(int[ ] a) If you are programming in C or C++, the function signature isint is121Array(int a[ ], int len) where len is the number of elements in the array a. Examples a is then function returns reason {1, 2, 1} 1 because the same number of 1s are at the beginning and end of the array and there is at least one 2 in between them. {1, 1, 2, 2, 2, 1, 1} 1 because the same number of 1s are at the beginning and end of…
- Create a program whose Main() method declares an array of 10 integers. Call a method to interactively fill the array with any number of values up to 10 or until a sentinel value is entered. If an entry is not an integer, re-prompt the user. Call a second method that accepts out parameters for the highest value in the array, lowest value in the array, sum of the values in the array, and arithmetic average. In the Main() method, display all the statistics.JAVA PROGRAM Write a program that asks the user to input two integers a and b. Then create an array that has all integer from a to b. Print out the array. (Don’t forget to consider the situation of a=b, a<b, and a>b.) Example 1: Input two numbers: 6 2 Array is [6, 5, 4, 3, 2] Example 2: Input two numbers: 4 8 Array is [4, 5, 6, 7, 8] Pass the above array as a parameter to a method called average and return the average and print it out in the main method. (Do not use Math library to get the average.)This is the question I am stuck on - In the exercises in Chapter 6, you created a class named Purchase. Each Purchase contains an invoice number, amount of sale, amount of sales tax, and several methods. Now, write a program that declares an array of five Purchase objects and prompt a user for their values. As each Purchase object is created, continuously prompt until the user enters an invoice number between 1000 and 8000 inclusive and a non-negative sale amount. Prompt the user for values for each object and then display all the values. This is the code that I am unsure where to fully start - public class Purchase { private int invoiceNumber; private double saleAmount; private double tax; private static final double RATE = 0.05; public void setInvoiceNumber(int num) { invoiceNumber = num; } public void setSaleAmount(double amt) { saleAmount = amt; tax = saleAmount * RATE; } public double getSaleAmount() { return…
- Write a test program that creates two hexagons (5) and (10) and compares them using method compareTo(). Also, create array of four comparable hexagons with side value (4), (6), (10) and (2). Pass the array as parameter to method max. You should get the following result. Comparing two Hexagons -1 Max hexagon with biggest number of sides is 10.0Create a program whose Main() method declares an array of 10 integers. Call a method to interactively fill the array with any number of values up to 10 or until a sentinel value is entered. If an entry is not an integer, re-prompt the user. Call a second method that accepts out parameters for the highest value in the array, lowest value in the array, sum of the values in the array, and arithmetic average. In the Main() method, display all the statistics.Java ProgramNeeds to be written in java: Write a program with a main() method that asks the user to input an integer array of 10 elements.Next, create three methods described below. From inside your main() method, call each of thethree methods described below and print out the results of the methods 2, 3, which return values.1. printReverse() - a method that receives an array of integers, then reverses the elements ofthe array and prints out all the elements from inside the method. Print all in one lineseparated by commas (see sample output below).2. getLargest() – a method that receives an array of integers, then returns the largest integervalue in the array. (print result from main())3. computeTwice()- a method that receives the previously reversed array of integers, thenreturns an array of integers which doubles the value of each number in the array (see thesample output below). (print result from main())Sample output:Enter a number:22Enter a number:34Enter a number:21Enter a number:35Enter a…
- In ArrayUtility class, create a public static method equals that receives two arrays of int's and returns true if they have the same length and equal corresponding elements. In ArrayUtilityTest class, create a public static method equalsTest that prints the results for the following 6 cases: two empty arrays, one empty and one singleton, two singleton with the same element, two singleton with different elements, two arrays with two identical elements, two arrays with two different elements. Call only this class in the main method and check the results. In ArrayUtility and ArrayUtilityTest, design, implement and test a method named isSorted that checks if an array of int-s is already sorted, i.e. all the elements are in increasing order. In ArrayUtility and ArrayUtilityTest, design, implement and test a method named generateIntArray that generates a random array with the provided length having elements randomly generated between a minimum and maximum value, including those values create…Write (define) a public static method named countGreaterThan, that takes an array of int, and an int as arguments and returns (as an int) a count of the number of values in the argument array that are greater than the second argument value. For example, given the following Array declaration and instantiation: int[] myArray = {1, 22, 333, 400, 5005, 9}; countGreaterThan(myArray, 200) should return 3 countGreaterThan(myArray, 9999) should return 0 You may wish to write some additional code to test your method. ------------------------------------------- public class Main { public static void main(String[] args) { // you may wish to write some code in this main method // to test your method. } // define your method(s) here below }Write a method combine(int a[], int b[]) which takes two sorted integer arrays, a[ ] and b[ ], and combines it into a single sorted array, c[]. The method should return the single sorted array.