Computer Science, asked by jasperkiran876, 9 months ago

write a java program that inputs 5 numbers, each between 10 and 100 inclusive. as each number is read display it only if it's not a duplicate of any number already read. display the set of unique values input after the user enters each new value.​

Answers

Answered by charansingh109105
7

Answer:

Java bava bajava ok bro lxkxlx

Answered by anjaliom1122
1

Answer:

How to get the unique values:

The distinct() function is an intermediate action that filters the stream before passing it on to the following process. The Java Stream collect() method in Java is used to collect stream elements into a collection (in this case a list). The return type is Stream, which is both an interface and a function.

Explanation:

Enter an integer between 10 and 100 :The complete set of unique values entered is:

Unique Value 1: is 100

Unique Value 2: is 10

Unique Value 3: is 20

import java.util.ArrayList;

import java.util.Scanner;

public class DuplicateElimination {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

ArrayList list = new ArrayList();

int num;

for (int i = 0; i < 5; ++i) {

System.out.print("Enter an integer between 10 and 100:");

num = in.nextInt();

if (!list.contains(num)) {

list.add(num);

System.out.println("This is the first time " + num + " has been entered");

}

}

for (int i = 0; i < list.size(); ++i) {

System.out.println("Unique Value " + (i+1) + " is " + list.get(i));

}

}

}

Similar questions