Write a program that displays all the non-prime numbers less than 100 in decreasing order. Use the StackOfIntegers class to store the non-prime numbers (e.g., 4, 6, 8, . . . ) and retrieve and display them in reverse order.
Q: Write a méthód called changeQueue to be considered inside the ArrayQueue class and has one parameter…
A: The program is written in Java. Check the program screenshot for the correct indentation. Please…
Q: Write a method called changeQueue to be considered inside the ArrayQueue class and has one parameter…
A: Language: JAVA Specifications: Non-Empty Queue i.e. Length > 0 Even number of elements, hence…
Q: Implement a new class that implements Comparatorof GregorianCalendar class to be able sort the…
A: The String[] having date as a string for 10 dates is created and initialized. Method private static…
Q: Write a client program that loops around getting two fractions from the user,output their sum, and…
A: Program code: Fraction.java //Define the class Fractionpublic class Fraction { // declaring instance…
Q: Please create a program in Java which will include a method that will merge sort an array of strings…
A: The code is given in the below step
Q: Write a static method isStrictlyIncreasing(double[] in) that returnstrue if each value in the given…
A: Static method for given problem:-
Q: Write a program called ListEvenNumbers wich prints the even numbers from 20 to 30 (including 30).…
A: As there is no programming language mentioned, we are doing this program in java to print even…
Q: Can you implement the Student class using the concepts of encapsulation? A solution is placed in the…
A: public class Student { private String name; private int rollNumber; public String getName() {…
Q: Write a program that uses a HashMap to compute a histogram of positivenumbers entered by the user.…
A: Here I have created an ArrayList to store the elements entered by the user. I have taken an infinite…
Q: Why are the methods getlndexOf and removeEntry in the class ArrayBag private instead of public?…
A: The methods contains implementation details that the customer should be unaware of. Thus aren't ADT…
Q: write a java program use the principle Encapsulation (set , get) to print multiply two numbers
A: Sample Response: //Java program to multiply two number by suing the principle of…
Q: A string containing text and possibly delimiters has been split into tokens and stored in String[]…
A: Below answer is coded in Java language.
Q: Write a method called changeQueue to be considered inside the ArrayQueue class and has one parameter…
A: class ArrayQueue{ public void changeQueue(int [] queue,int item){ int n=queue.length; for(int…
Q: rite a program that reads a text file and creates an alphabetical index of words and in which lines…
A: sentence = input("enter the sentence:") string = sentence.lower() print(string) count = 0…
Q: Write a program that reads a list of integers, and outputs the two smallest integers in the list, in…
A: #include <stdio.h>#include <stdlib.h>#include <limits.h> int main(){ int…
Q: 2. Write a Java Program to create the given Sets with String values and perform the following…
A: Set is a type of collection that does not allow duplicate elements. That means an element can only…
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: 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: 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: Write a program that reads a list of integers, and outputs the two smallest integers in the list, in…
A: import java.util.*;public class Main{public static void main(String[] args) { int…
Q: Consider the binary search method presented in class and shown below. Suppose the method is called…
A: (B) The method will work correctly, even if there are duplicate values, just as long as it is…
Q: Write a method called samePosition in a class called stackExt that receives two parameters st1 and…
A: ArrayStack is a class which holds collection of Integer objects <Integer> wrapper class used…
Q: Write a program that draws line segmentsusing the arrow keys. The line starts from (100, 100) in the…
A: Program structure Import required JavaFX classes in the program. Create a class ArrowLines that…
Q: The split method in the String class returns an array of strings consisting of the substrings split…
A: import java.util.Arrays;public class Main { public static String[] split(String s, String regex) {…
Q: Please implement in Java implement a keyed bag in which the items to be stored are strings (perhaps…
A: Given data, implement a keyed bag in which the items to be stored are strings (perhaps people’s…
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: Write a program that prompts the user to enter apositive integer and displays all its smallest…
A: Let us consider a Java program that prompts the user to enter a positive integer and displays all…
Q: Write a Java method int I] evenoddSwap(int [ nums) that given an integer array containing the same…
A: The question is to write JAVA code for the given problem.
Q: Write a java code that sorts a list of n items by dividing it into three sublists of about n/3…
A: Actually, java is a object oriented programming language. It is a platform independent.
Q: Write a program that uses an object of type ServiceRequests to keep track of customers that have…
A: File name: ServiceRequests.java import java.util.Scanner;import java.util.*;import…
Q: We know that the first file name is stored at index zero in the ArrayList, and the list stores the…
A: Yes we can write the body of method listAllfiles along with the following lines given below. Given…
Q: Write a java program that: (You must use either a set or a map to solve the method) You are given n…
A: Program Approach: Import files HashSet class is used. AbstractSet is extended by HashSet, which…
Q: Write a program that prompts the user to enter a positive integer which is greater than one and…
A: Let us consider a Java program that prompts the user to enter a positive integer and displays all…
Q: In java, Write a method void popMult(int k) for the ArrayBoundedStack class which will pop k items…
A: ANSWER:-
Q: be adding all the cards
A: public class Card { private String mySuit; private int myValue; public Card(…
Q: Write a class MySortedArrayCollection that Inherit the SortedArrayCollection class show in screen…
A: Collections in Java The Collection in Java is a system that gives an engineering to store and…
Q: Write a program that will count the number of odd values and the number of even values in a…
A: Given:
Q: Write a program that displays all the prime numbersless than 120 in decreasing order. Use the…
A: Program: StackOfIntegers.java: // Class definition to store the prime numbers less than 120 in…
Q: do the changes in this program according to the given instruction import java.util.*; class…
A: Given:-
Q: Write a method called samePosition in a class called StackExt that receives two parameters st1 and…
A:
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: Write a program that receives an integer and displays its first ten multiples in decreasing order.…
A: Class stack is a predefined class in Java and a subclass of class vector. It can be used to make a…
Q: Write code in java for bookstore where is object sequentially aggregated, list of book name, year of…
A: Code: import java.util.ArrayList;import java.util.Iterator; class BookStore { String book_name,…
Q: Implement a method called has22, which inputs a list of ints, returns True if the array contains a 2…
A: Introduction: Algorithm: Define a function with the parameter num. Initialize the variable i to 0.…
Q: Write a method evensum that returns the sum of the values in even indices in a list of integers.…
A: front is storing the first node address and then through this we can iterate till last node by…
Q: Using a map and a set as auxiliary storages, write a static method search that accepts a string list…
A: EXPLANATION: - The ArrayList is created to store the strings, using the add method. The list…
Q: Write a program to add an additional $2,000award if two digits from the user input are in the…
A: A Java program for the given criteria is as follows, File name: “TestClass.java” import java.util.*;…
Q: In this exercise, you will code a modified version of sequential search from the previous example.…
A: Given: In this exercise, you will code a modified version of sequential search from the previous…
Write a program that displays all the non-prime numbers less than 100 in decreasing order. Use the StackOfIntegers class to store the non-prime numbers (e.g., 4, 6, 8, . . . ) and retrieve and display them in reverse order.
Step by step
Solved in 2 steps
- Write a program that displays all the prime numbersless than 120 in decreasing order. Use the StackOfIntegers class tostore the prime numbers (e.g., 2, 3, 5, . . . ) and retrieve and display them inreverse order.Write a program that receives an integer and displays its first ten multiples in decreasing order. For example, if the integer is 5, he first ten multiples are displayed as 50, 45, 40, 35, 30 25, 20, 15, 10, 5. Use the StackOfIntegers class to store the multiples (e.g., 5, 10, ..., 50) and retrieve and display the multiples in reverse order.Provide a different implementation of ChoiceQuestion. Instead of storing the choices in an array list, the addChoice method should add the choice to the question text. For this purpose, an addLine method has been added to the Question class. Use the following files: Question.java /** A question with a text and an answer.*/public class Question{ private String text; private String answer; /** Constructs a question with empty text and empty answer. */ public Question() { text = ""; answer = ""; } /** Sets the answer for this question. @param correctResponse the answer */ public void setAnswer(String correctResponse) { answer = correctResponse; } /** Checks a given response for correctness. @param response the response to check @return true if the response was correct, false otherwise */ public boolean checkAnswer(String response) { return response.equals(answer); } /** Add a line of text to…
- Develop a class ResizingArrayQueueOfStrings that implements the queueabstraction with a fixed-size array, and then extend your implementation to use arrayresizing to remove the size restriction.Develop a class ResizingArrayQueueOfStrings that implements the queueabstraction with a fixed-size array, and then extend your implementation to use arrayresizing to remove the size restriction.Write a program that prompts the user to enter apositive integer and displays all its smallest factors in decreasing order. Forexample, if the integer is 120, the smallest factors are displayed as 5, 3, 2, 2,2. Use the StackOfIntegers class to store the factors (e.g., 2, 2, 2, 3, 5) andretrieve and display them in reverse order.Write a Java application CountryList. In the main method, do the following:1. Create an array list of Strings called countries.2. Add "Canada", "India", "Mexico", "Peru" in that order.3. Use the enhanced for loop to print all countries in the array list, one per line.4. Add "Spain" at index 15. Replace the element at index 2 with "Vietnam". You must use the set method.6. Replace the next to the last element with "Brazil". You must use the set method. You willlose one point if you use 3 in the set method. Do this in a manner that would replace thenext to the last element, no matter the size of the array list.7. Remove the object "Canada" Do not remove at an index. Your code should work if"Canada" was at a different location. There is a version of remove method that willremove a specific object.8. Get and print the first element followed by "***"9. Call method toString() on countries to print all elements on one line.10. Use the enhanced for loop to print all countries in the array list,…
- Please use java. Show the steps with pictures. In this assignment, you will implement a class calledArrayAndArrayList. This class includes some interesting methods for working with Arrays and ArrayLists. For example, the ArrayAndArrayList class has a “findMax” method which finds and returns the max number in a given array. For a defined array: int[] array = {1, 3, 5, 7, 9}, calling findMax(array) will return 9. There are 4 methods that need to be implemented in the A rrayAndArrayList class: ● howMany(int[] array, int element) - Counts the number of occurrences of the given element in the given array. ● findMax(int[] array) - Finds the max number in the given array. ● maxArray(int[] array) - Keeps track of every occurrence of the max number in the given array. ● swapZero(int[] array) - Puts all of the zeros in the given array, at the end of the given array. Each method has been defined for you, but without the code. See the javadoc for each method for instructions on what the…Please use java only and public int method. Show the steps with the pictures also. In this assignment, you will implement a class calledArrayAndArrayList. This class includes some interesting methods for working with Arrays and ArrayLists. For example, the ArrayAndArrayList class has a “findMax” method which finds and returns the max number in a given array. For a defined array: int[] array = {1, 3, 5, 7, 9}, calling findMax(array) will return 9. There are 4 methods that need to be implemented in the A rrayAndArrayList class: ● howMany(int[] array, int element) - Counts the number of occurrences of the given element in the given array. ● findMax(int[] array) - Finds the max number in the given array. ● maxArray(int[] array) - Keeps track of every occurrence of the max number in the given array. ● swapZero(int[] array) - Puts all of the zeros in the given array, at the end of the given array. Each method has been defined for you, but without the code. See the javadoc for each…Write a class Employee with name and salary. Create an ArrayList whichsorts the Employees based on salary. Use any sorting technique mentionedin Section 7.4 of Chapter 7.
- JAVA Create a new class HashSetManipulation with a main method. Create a new HashSet set and populate it with initial values "A", "B", and "C" using the add method. Print the size of the set using set.size(). Use a for loop to print the values in the set. Use the add method to add a new value "D" to the set and print the result of the set to show that the value has been added. Use the remove method to remove value "A" from the set and print the result of the set to show that the value has been removed. Use the contains method to check if the value "C" exists in the set and print the result.Define a class called Book. This class should store attributes such as the title, ISBN number, author, edition, publisher, and year of publication. Provide get/set methods in this class to access these attributes. Define a class called Bookshelf, which contains the main method. This class should create a few book objects with distinct names and store them in an ArrayList. This class should then list the names of all books in the ArrayList. Enhance the program by providing a sort function, which will sort the books in ascending order of their year of publication. Create a few more Bookobjects with the same names but with different edition numbers, ISBNs, and years of publication. Add these new Book objects to the ArrayList, and display the book list sorted by book name; for duplicate books of the same name, sort the list by year of publication. (Hint: You will need to define a comparator class that takes two Book objects as parameters of the compareTo This method should do a two-step…Phone numbers and PIN codes can be easier to remember when you find words that spell out the number on a standard phone pad. For example, instead of remembering the combination 5282, you can just think of JAVA. Make a recursive method that, given a number, yields all possible spellings (which may or may not be real words). This assignment needs a resource class and a driver class. The resource class and the driver class need to be in two different files. The resource class will contain all of the methods and the driver class only needs to call the methods. The driver class needs to have only 5 lines of code. The code needs to be written in Java. Please help me with exactly what I asked for help.