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 more than what was returned the previous time next was called,
> stream.next() 10 > stream.next() 11 > stream.next() 12
StringStream: A string stream produces a continuous sequence of strings that consist of lower case letters, in lexicographical order. (The strings in lexicographical order are: { "", "a", "b", ..., "z", "aa", "ab", ..., "az", "ba", "bb", ..., "bz", ..., "zz", "aaa", "aab", ...}.) The class will need the following methods and constructors:
The constructor takes a String that represents the first value returned by the stream. (The behavior if the input is not all lowercase letters is up to you.)
next: Takes no input and returns the next value of the stream, i.e. it returns the string that is next in the lexicographical ordering from the previous value returned by next.
> stream.next() "pez" > stream.next() "pfa" > stream.next() "pfb"
The java code is as follows:
public class IntegerStream {
private int number;
// defining IntegerStram constructor which take one value
IntegerStream(int value){
number=value;
}
// Defining next method which returns an integer
int next(){
return number++;
}
public static void main(String args[]){
// creating the object for IntegerStream class
IntegerStream stream = new IntegerStream(10);
System.out.println(stream.next());
System.out.println(stream.next());
System.out.println(stream.next());
}
}
output:
The output is at the bottom
of the page
The java code for StringStramer is:
public class StringStream {
String str;
static int count =0;
StringStream(String value){
str=value;
}
String next()
{
if (count==0){
count++;
return str;
}else{
// if string is empty
if (str == "")
return "a";
// Find first character from
// right which is not z.
int i = str.length() - 1;
while (str.charAt(i) == 'z' && i >= 0)
i--;
// If all characters are 'z',
// append an 'a' at the end.
if (i == -1)
str = str + 'a';
// If there are some
// non-z characters
else
str = str.substring(0, i) +
(char)((int)(str.charAt(i)) + 1) +
str.substring(i + 1);
if (i==str.length() - 2){
str =changeCharInPosition(str.length()-1, 'a', str);
}
return str;
}
}
public String changeCharInPosition(int position, char ch, String str){
char[] charArray = str.toCharArray();
charArray[position] = ch;
return new String(charArray);
}
public static void main(String args[]){
// creating the object for StringStream class
StringStream stream = new StringStream("pez");
System.out.println(stream.next());
System.out.println(stream.next());
System.out.println(stream.next());
}
}

I hope you got the answer and understand it.
Thank you:):)
In Java IntegerStream: An integer stream produces a continuous sequence of integers, starting at some initial...
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...
Java A bigram is a pair of adjacent words in a sequence. Bigrams overlap so that in the sequence "a b. c d", the bigrams are ("a", "b."), ("b.", "c"), ("c", "d"). You will write a simple parser which builds a bigram model based on input text and will allow checking sentences and generating sequences. To do so, you should take advantage of Java’s collection classes including Maps. Create a class called Bigram. The class will have a constructor which...
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,...
Programming project in Java: You are allowed to use the following methods from the Java API: class String length charAt class StringBuilder length charAt append toString class Character any method Create a class called HW2 that contains the following methods: 1. isAlphabeticalOrder takes a String as input and returns a boolean: The method returns true if all the letters of the input string are in alphabetical order, regardless of case. The method returns false otherwise. Do not use arrays to...
The following code must be written and run with no errors in java eclipse Description of the code to be written: A resistor is an electronic part colour-coded with three coloured bands to indicate its resistance value. This program returns the resistance of a Resistor object instantiated with three Strings, representing the three colour bands of a real resistor. Start by creating an abstract class 'AbstractResistor' that implements the Comparable interface. This class should have the following three private methods:...
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...
This lab will exercise your understanding of some of the concepts covered in Chapter 10: classes, default constructors, overloaded constructors, arrays of classes A Roman numeral represents an integer using letters. Examples are XVII to represent 17, MCMLIII for 1953, and MMMCCCIII for 3303. By contrast, ordinary numbers such as 17 or 1953 are called Arabic numerals. The following table shows the Arabic equivalent of all the single-letter Roman numerals: M 1000 X 10 D 500 V 5 C...
Create a UML diagram to help design the class described in exercise 3 below. Do this exercise before you attempt to code the solution. Think about what instance variables will be required to describe a Baby class object; should they be private or public? Determine what class methods are required; should they be private or public? Write Java code for a Baby class. A Baby has a name of type String and an age of type integer. Supply two constructors:...
Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...
Deliverable
A zipped NetBeans project with 2 classes
app
ZipCode
Address
Classes
Suggestion:
Use Netbeans to copy your last lab (Lab 03) to a new
project called Lab04.
Close Lab03.
Work on the new Lab04 project then.
The Address Class
Attributes
int number
String name
String type
ZipCode zip
String state
Constructors
one constructor with no input parameters
since it doesn't receive any input values, you need to use the
default values below:
number - 0
name - "N/A"
type...