Write a program that uses an object of type ServiceRequests to keep track of customers that have called. It should have a loop that, in each iteration, attempts to add a name, remove a name, or print all names. Use an array of size 10 as the list of names.
Q: Write a method called append that accepts two integer arrays as parameters and returns a new array…
A: Declare a static method append() which takes two integer arrays as parameters. This method does not…
Q: Write a program to generate 1000 random numbers between 1 and 500, stored in an ArrayList, then…
A: import java.io.*;import java.util.*;public class Solution{ public static void main(String[]…
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: This is a partially implemented class called UnsortedMapOfLists, which extends UnsortedTableMap. The…
A: Brief Introduction: We have to write a code in Python that will make sure that the gcd of numbers…
Q: an ArrayList of ArrayLists
A: Given :- An ArrayList of ArrayLists is given in the above mention question and each inner ArrayList…
Q: .Write a method named fill that fills all elements of an array of integers with a given value. For…
A: Iterate over the entire array Fill each number with given value
Q: Modify the BookStore and BookSearchEngine classes explained in the class to include the following…
A: Code and Output start from step-2.
Q: Write a Java program that uses ArrayList and Iterator. It should input from user the names and ages…
A: Given:
Q: write a method called secondLargest that takes an array of integers and returns the second largest…
A: Algorithm : secondLargest function Step 1 : declaring variable. Step 2 : storing the length of the…
Q: Write a method called oddSum which will return the sum of all values stored in the odd indices of a…
A: We will call the method oddSum from the main method. We will use an array that is already…
Q: Rewrite the following by using the static arraycopy method of the System class: int[] copy = new…
A: In this we copy our original array into copy array int[] copy = new int[original.length]; for(int…
Q: If a method given an ArrayList as a parameter calls a second method giving it the same ArrayList,…
A: The answer is given below.
Q: Write a method that takes an argument representing an array, orig,and returns a new array that is…
A: Create a new array which is having the excess length of half Then, copy the values and the remaining…
Q: Write a method that takes an integer array, prints the elements that are divisible by 3 and returns…
A: Here, According to the instruction we will take an array and print the elements which are divisible…
Q: Consider the IntArrayBag collection class that we discussed in class, Draw the data array after…
A: SUMMARY: - hence we discussed all the points.
Q: Write a method quicksort that takes in an ArrayList of integers and returns them in ascending order,…
A: import java.util.ArrayList; public class Quicksort { static int partition(int arr[], int low,…
Q: Write a Java program, called LinearSearch2, that contains a static method called countStrings() that…
A: Java program to solve the given problem is below.
Q: Given an ArrayList named receipts, which answer puts the following values into receipts: 12.43,…
A: Given an ArrayList named receipts, which answer puts the following values into receipts: 12.43,…
Q: Write a method that takes two arrays of integers and combines the two arrays into one array with…
A: NOTE: SINCE THE LANGUAGE OF THE CODE IS NOT MENTIONED, I HAVE USED JAVASCRIPT FOR THE SOLUTION.…
Q: Complete the Course class by implementing the printRoster() method, which outputs a list of all…
A: To implement the required printRoster( ) function, the following 2 steps are to be taken:- Iterate…
Q: Use the Iterator Pattern: Create a class called Exercise, and then, in its main method, create an…
A: Given data, Use the Iterator Pattern: 1. Create a class called Exercise, and then, in its main…
Q: 5. Write a static method largestColumnFirst() that receives as parameter a 2D array numAr, finds the…
A: //NOTE: SINCE programming language is not specified, we are providing answer in java public class…
Q: Your program will read in a list of high and low integer temperatures and city names from System.in…
A: Required: Your program will read in a list of high and low integer temperatures and city names from…
Q: Write a method with the name "eraser" that will get two arguments: “maparr_plants" (Map array of…
A: Here we have to provide the key for containsKey and remove methods not the indices. So the updated…
Q: Consider a 2D int-array that contains the brightness values of the pixels in an image. Write a…
A: please do support for my efforts, thanks! answer: #include <bits/stdc++.h>using namespace…
Q: Write a method called mins() that takes one parameter: a two-dimensional array of ints called nums.…
A: Method://Method definitionpublic static int [] mins(int[][] mins){//Create a two-dimensional…
Q: Given the array list of primes below, write a loop to print its elements in reverse order, starting…
A: File name: “PrimesDemo.java” import java.util.ArrayList; public class PrimesDemo { public…
Q: Your program will read in a list of high and low integer temperatures and city names from System.in…
A: ThreeWaySortTemperatures.java: //This class is used to print the cityName lowest temperature and…
Q: This question is in Java. You are given an ArrayList of ArrayLists, each ArrayList contains…
A: Convert everything into Streams, the outer ArrayList and the inner ones, Filter over the inner…
Q: in python """ Write a function get_new_grades, such that given a string of grades as an input…
A: Below is the code in python and sample output:
Q: Write a program with a main() method that asks the user to input an integer array of 10 elements.…
A: - The question is to code the provided program with the described functions.
Q: Write a method sumAL() that takes an ArrayList of integers as parameter, returns the sum of numbers…
A: The problem is based on the basics of arraylist and funtions in java.
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: You are implementing a board game where you are given a size M x N for the board, where M is the…
A: Python and java use to answer the question
Q: Write a RainFall class that stores the total rainfall for each of 12 months into an array of…
A: So the Rainfall class will be having a total of 4 methods and main function to call these and print…
Q: sume you have a method (shown below) inside the ArrayQueue class public void unknown() {ifsize == 0)…
A: Here is the explanation:
Q: Write a method named swapPairs that accepts an array of strings as a parameter and switches the…
A: To solve the given problem, In the swapPairs() method we need to switch the order of the first two…
Q: Write a program that reads words into two ArrayLists list1 and list2 and then creates a third…
A: import java.io.*;import java.util.*;public class MyClass { public static void main(String args[])…
Q: 1. write a static method that receive as parameter an array of type student and print the names of…
A: This is a multiple type question, so according to the guidelines, the first question has been…
Q: in a loop that continues until a user inputs a sentinel value of Z, ask the user whether the…
A: Program Understanding Here, we have used a while loop that continues until a user enters 'Z' to…
Q: Need help writing the method: getWaitlistedIDs() – returns an array of type int[], namely the ids of…
A: Note: In this question we are asked to modified getWaitlistedIDs method only in java There is a…
Q: Write a program to test your implementation by reading data related to 50 Car objects and store them…
A: **THIS CODE IS WRITTEN IN JAVA SINCE NO PROGRAMMING LANGUAGE WAS MENTIONED ** READ THE COMMENTS…
Q: Write a method that takes two arrays of integers and combines the two arrays into one array with…
A: Step 1 : create mergeArray2 method with two arguments of array Step 2 : declare new array merged…
Q: In Java, we can create an array of class objects. True O False
A: True
Q: I need to write a program called Deleted_position.java that has a method with one int array as a…
A: GIVEN: I need to write a program called Deleted_position.java that has a method with one int array…
Q: Make a method with prototype: public static…
A: The programming methodology is given by: Importing packages Main class Method SumOfEvenNumbers…
Write a program that uses an object of type ServiceRequests to keep track of customers that have called. It should have a loop that, in each iteration, attempts to add a name, remove a name, or print all names. Use an array of size 10 as the list of names.
Step by step
Solved in 2 steps with 1 images
- Write a program that creates array of 10 integers. Ask the user to enter the data in the array. Each time the data entered in the array should be unique. Your program should not allow the user to enter the duplicate values in the array. After feeding data into the array created, create another array of the 10 integers and save the data of 1st array in the reverse order into the second array. For Example Array 1 1 2 3 4 5 6 7 8 9 10 Array 2 10 9 8 7 6 5 4 3 2 12. write two method called findIndex and findLastIndex that search for a number in an array. they should take an int array and an int as parameters. findIndex should return the index of the first instance of the number in the array. findLastIndex should return the index of the last instance of the number in the array. They both should return -1 if the number is not found. Do not use any library methods. Sample code int a[] int x = findIndex(a,50); Sample output {10,50,30, 40,50}; 1 System.out.println(x); int a[] int x = findLastIndex (a,50); System.out.println(x); int a[] = {10,50,30,40,50}; int x = findIndex(a,70); {10,50,30,40,50}; 4 -1 System.out.println(x);Write a program, Passwords , that contains an array of five names and another array of five passwords. Your program should ask the user to enter a name and a password. If the user enters the correct name with its related password, grant access (e.g. display “Access granted!”). IF the user enters the wrong name/password (can be either or both), allow the user to re-try only once. If the user still cannot enter the correct name/password, display the following: “Sorry, your username/password does not match our database. Contact the administrator.”
- Write a program that simulates rolling two dice. Prompt the user to enter the number of dice rolls. Use a loop to repeatedly call a method that simulates a dice roll and returns the total of the two dice to main. Keep track of the rolls in an array in main, and end the program by showing the results of the rolls.3. write a method called insert that inserts an element into an integer array. It should take 3 parameters: an int array, the number to be inserted and the index it should be inserted at. It should return a new array that has the element inserted at the index (the new array should have a length 1 longer than the original array).Create a class containing the main method. In the main method, create an integer array and initialize it with the numbers: 1,3,5,7,9,11,13,15,17,19 Pass the array as an argument to a method. Use a loop to add 1 to each element of the array and return the array to the main method. In the main method, use a loop to add the array elements and display the result. Note: In the loops, use the array field that holds the length of the array and do not use a number for array length.
- This program is written in java. 2D arrays (matrices/grids) Write a program that takes 20 student objects and stores them in an array. Each Student object should have a first name and a last name. Sort the array by student’s last name. You can use any of the sorts you have. Then put the names into a 2D array that has 5 rows and 4 columns. Create and print 2 seating charts by printing the 2D array, formatted as shown below. Student 17 Student 18 Student 19 Student 20 Student 13 Student 14 Student 15 Student 16 Student 9 Student 10 Student 11 Student 12 Student 5 Student 6 Student 7 Student 8 Student 1 Student 2 Student 3 Student 4 second chart should look randomized, like this. Student 4 Student 8 Student 12 Student 16 Student 20 Student 3 Student 7 Student 11 Student 15 Student 19 Student 2 Student 6 Student 10 Student 14 Student 18 Student 1 Student 5 Student 9 Student…In this project you will generate a poker hand containing five cards randomly selected from a deck of cards. The names of the cards are stored in a text string will be converted into an array. The array will be randomly sorted to "shuffle" the deck. Each time the user clicks a Deal button, the last five cards of the array will be removed, reducing the size of the deck size. When the size of the deck drops to zero, a new randomly sorted deck will be generated. A preview of the completed project with a randomly generated hand is shown in Figure 7-50.Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception.
- Write a method with header static void DisplayIntArray(int[] numbers). The first argument is an array of ints. There is no return value. This method displays all the elements of the argument on a single line. Each item will occupy three columns.Call this method from main with a suitable argument. Write a method with header static int[] GenerateRandomIntArray(int numberOfItems, int largestValue). The first argument is an int indicating the number of elements that will be present in the return array. The second argument is an int representing the largest item in the array. The returned value is an array of integers. This method does the following: Declare and initialized a variable of type Random (Random generator = new Random();) Declare an array of type int (you may call it result) Allocate storage for the correct number of items Using your favorite looping statement, assign a random integer to each element of the array (result[i] = generator.Next(largestValue);) In your…3. write a method called insert that inserts an element into an integer array. It should take 3 parameters: an int array, the number to be inserted and the index it should be inserted at. It should return a new array that has the element inserted at the index (the new array should have a length 1 longer than the original array). Sample code int[] a = {1,2,3,4,5}; int[] inserted = insert (a,9,0); printArray (inserted); int [] a = {1,2,3,4,5}; int[] inserted = insert (a,9,3); printArray(inserted); int [] a = {1,2,3,4,5}; int[] inserted = insert(a,9,5); | printArray(inserted); Sample output 912345 123945 123459Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception. Ex: Enter Day: 1Monday is available, enter Name: Tomas[Tomas, , , , ]Enter Day: 3Wednesday is available, enter Name: Sheldon[Tomas, ,Sheldon, , ]Enter Day: 3Wednesday is not available, choose other day: 2Tuesday is available, enter Name: Raj[Tomas,Raj,Sheldon, , ]Enter Day: 4Thursday is available, enter Name: Leonard[Tomas,Raj,Sheldon,Leonard, ]Enter Day: 0Invalid DayEnter Day: AInvalid DayEnter Day: 5Friday is available, enter Name:…