In Java!
NotMultipleStream: a stream that returns, in numeric order, integers that are not multiples of a certain value, starting from an initial value. The NotMultipleStream should behave like an IntegerStream, but it should include a NotMultipleFilter to filter out multiples of a certain value. The class will need the following methods and constructors:
The constructor takes two integer values. The first is the base value and the second is the initial value.
next: takes no input and returns an integer. The first value returned by next should be the the smallest number, no smaller than the initial value such that the number is not divisible by the base value. Each subsequent call should return the next largest integer that is not a multiple of the base value.
NOTE: Lines starting with // are comments, screen shot of code and testing class and outputs is provided below
_________________________________________________________________________
class NonMultipleStream{
//decalare variables
int base;
int initVal;
static int currentNum;
NonMultipleStream(int base,int initVal){
this.base=base;
this.initVal=initVal;
this.currentNum=initVal;
}
//method to return next Integer of the Stream
public int next(){
//loop
while(true){
//check if
currentNum is divisible by base
if(currentNum%base!=0){
//return the number
this.currentNum++;
return this.currentNum-1;
}
else
//increment current number
this.currentNum++;
}
}
}
________________________________________________
import java.util.Scanner;
import java.io.*;
class TestNonMultipleStream{
public static void main(String[] args) {
//decalre variables
int base,initval;
//create scanner class object
Scanner s=new Scanner(System.in);
//prompt user to enter input
System.out.print("Enter base value:");
base=s.nextInt();
System.out.print("Enter Initial Vaule:");
initval=s.nextInt();
//create object of NonMultipleStream Class
//pass inputs as arguments to constructor
NonMultipleStream nsm=new
NonMultipleStream(base,initval);
System.out.println("Stream Outputs:");
System.out.println(nsm.next());
System.out.println(nsm.next());
System.out.println(nsm.next());
System.out.println(nsm.next());
System.out.println(nsm.next());
System.out.println(nsm.next());
System.out.println(nsm.next());
}
}
____________________________________________________________
CODE screen shots:


__________________________________
Outputs:

In Java! NotMultipleStream: a stream that returns, in numeric order, integers that are not multiples of...
In Java IntegerStream: An integer stream produces a continuous sequence of integers, starting at some initial integer. Each subsequence integer produced should be one more than the previous integer. The class will need the following methods and constructors: The constructor takes an integer that represents the first value returned by the stream. next(): Takes no input and returns the next value of the stream starting at the initial value. Each time next is called, the number returned should be one...
I need to write a C++ program that reads two integers from a data filed called "integers.dat" The first integer should be low and the other one high. The program should loop through all integers between the low and high values and include the low and high integers and then display Display the integers in the file Displays the number of integers divisible by 5 OR 6, but not both. Displays the sum of the integers from condition 2 as...
Write a JAVA program to read a list of nonnegative integers and to display the largest integer, the smallest integer and the average of all the integers. The user indicates the end of the input by entering a negative sentinel value that is not used in finding the largest, smallest and average values. The average should be a value of type double so that it is computed a fractional part. * Java program free from syntax, logic and run time...
In Java,enhace the program base on the first one. 1. You are going to design (and code) a class called Name. The class Name will contain three properties: first, the first name which is a String initial, the middle initial, which is a single character. last, the last name, which is a String The class has three constructors: A default constructor, which accepts no parameters, calls constructors for the first and last name and sets the initial equal to a...
DESCRIPTION: The range of integers that can be represented in Java using a primitive data type is only from-263 to 263-1. What if we need to manipulate integer values beyond this range? In this assignment you will write a HugeInteger class which is able to represent arbitrar- ily large integer numbers. This class must implement arithmetic operations on integers such as addition, subtraction, multiplication, division and comparison. You have to implement this class without using Java predefined classes, unless specified...
I need java code for the following problem.
Lab 7: Methods 1. Write a Java program called Numbers that calls the following methods and displays the returned value: Write a method called cubelt that accepts one integer parameter and returns the value raised to the third power as an integer. o Write a method called randominRange that accepts two integer parameters representing a range. The method returns a random integer in the specified range inclusive. 2. o Write a method...
(Java Programmin): Sum() and max() in ArrayList a. Write a method that returns the maximum value in an ArrayList of integers. The method returns null if the list is null or the list size is 0. public static Integer max(ArrayList<Integer> list) b. Write a method that returns the sum of all numbers in an ArrayList: public static Integer sum(ArrayList<Integer> list) c. Write a test program that prompts the user to enter a sequence of numbers ending with 0, and invokes...
You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...
java language please. thank you
T-Mobile 9:00 AM For this assignment, create a Java class named "MyRectangle3d" Your class must have the following attributes or variables · x (the x coordinate of the rectangle, an integer) * y (the y coordinate of the rectangle, an integer) * length (the length of the rectangle, an integer) * width (the width of the rectangle, an integer) * height (the height of the rectangle, an integer) * color( the color of the rectangle,...
Java question Q1) Use the following code snippet which generates a random sized array with random contents to complete the following problems: public int [] createRandomArray() { int size = (int) (Math.random() * 10) + 1; int[] array = new int [size]; for (int i = 0; i < array.length; i++) { array[i] = (int) (Math.random() * 10 ) + 1; } return array; } Assignment...