1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NeX [460]
3 years ago
5

Write a filter that reads in a sequence of integers and prints the integers, removing repeated values that appear consecutively.

For example, if the input is 1 2 2 1 5 1 1 7 7 7 7 1 1 1 1 1 1 1 1 1, your program should print 1 2 1 5 1 7 1.
Computers and Technology
2 answers:
lara31 [8.8K]3 years ago
7 0

Answer:

Following is the code for filter:

public class filter

{ public static void main(String[] args)

{ int x = StdIn.readInt();

System.out.print(" " + x + " ");

while(!StdIn.isEmpty())

{ int y = StdIn.readInt();

    if(y != x)

          System.out.print(" " + y + " ");

    x = y;

    }

    }

    }

Explanation:

  • A public class filter is used.
  • The main function will accept a single argument as string[], it is also known as java command line argument.
  • Now the Stdln.readInt is used to read the integers in the sequence and store it in integer x.
  • The value stored in variable x will be printed using System.out.print
  • Now unless the Stdln.readInt gets an empty value, check each value of sequence and store in variable y.
  • If y is not equal to previous value x, print it and shift the value of y into x.
  • Repeat the loop again.

i hope it will help you!

kykrilka [37]3 years ago
4 0

Answer:

Computer

Explanation:

You might be interested in
While engineers work to create computers that can understand us emotionally, ________ are also evolving toward a more human appe
aleksandrvk [35]
While engineers work to create computers that can understand us emotionally, ________ are also evolving toward a more human appearance.

affecting computing techniques
8 0
3 years ago
What is best defined as a phishing email that is targeted directly at you?.
Inga [223]

Answer:

spear phishing hope its right

6 0
2 years ago
In PowerPoint _____ management is extremely important and you must keep track of what links, files, and programs are placed in w
harkovskaia [24]

Answer: File

Explanation:

In PowerPoint _file_ management is extremely important and you must keep track of what links, files, and programs are placed in which folders.

File Management is extremely important because it is necessary for effective system administration.

A good file management system in powerpoint makes compactness, data retrieval and editing achieveable.

6 0
2 years ago
Algorithm and flowchart:- find the product of two number (a and b)​
Korvikt [17]

Answer:

i have no idea a i guess

Explanation:

5 0
3 years ago
Why are wiki's not secure​
Nookie1986 [14]
Wikipedia is not a reliable source for citations elsewhere on Wikipedia. Because, as a user-generated source, it can be edited by anyone at any time, any information it contains at a particular time could be vandalism
7 0
2 years ago
Other questions:
  • Which letters appear in the home row on a keyboard?
    14·2 answers
  • How does scarcity affect what gets produced
    5·1 answer
  • Write a method called printRange that accepts two integers as arguments and prints the sequence of numbers between the two argum
    6·1 answer
  • Please answer this a due tomorrow!!!
    5·1 answer
  • Computers that belong to the same domain can access a common security database of user and computer account information. This ty
    5·1 answer
  • 60 POINTS!
    13·1 answer
  • What happens when the following code segment executes if test.txt does not exist?:<br> A,B,C,D?
    7·1 answer
  • Gmod how to make someone admin on a lan server
    6·2 answers
  • Which of the selections below is not a benefit of imaging the computers on your network? There are fewer licensing fees because
    11·1 answer
  • What blockchain implementation resulted from bitcoin’s rejection of a recommendation to enhance its scripting language support?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!