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
devlian [24]
2 years ago
7

Write a program that reads in ten numbers and displays the number of distinct numbers and the distinct numbers separated by exac

tly one space (i.e., if a number appears multiple times, it is displayed only once).
(Hint: Read a number and store it to an array if it is new. If the number is already in the array, ignore it.)

After the input, the array contains the distinct numbers in the order of their input.
Computers and Technology
1 answer:
ELEN [110]2 years ago
6 0

Answer:

The program to this question can be given as:

Program:

//import package.

import java.util.*;

public class Main //defining the class

{

public static void main(String[] args) //defining main method  

{

 Scanner ob = new Scanner(System.in); //creating scanner class object.

 int[] a = new int[10];//define array.  

 int number,counts= 0,i;//define variable.

 System.out.print("Enter numbers: "); //message.

 for (i = 0; i < 10; i++) //loop  

 {

  number=ob.nextInt();

  if (isDistinct(a,number))

  {

      a[counts] = number;//assign value in array

      counts++; // Increment count

  }

 }

 System.out.println("The distinct numbers is :" + counts);

 System.out.print("The distinct number are :");

 for (i = 0; i <a.length; i++)//loop

 {

  if (a[i] > 0)

  {

   System.out.print(" " +a[i]);//print array.    

  }

   

 }

 System.out.println();

}

public static boolean isDistinct(int[] array, int num)//defining method  

{

 for (int i = 0; i < array.length; i++)//loop for check number  

 {

  if (num == array[i]) //check condition

  {

      return false; //return value false.

  }

 }

 return true; //return value true

}

}

Output:

First time run:  

Enter ten numbers: 1 2 3 4 5 6 7 8 9 10

The number of distinct numbers is 10

The distinct numbers are 1 2 3 4 5 6 7 8 9 10

Second time run:

Enter numbers: 2 3 5 8 7 4 3 2 1 2

The distinct numbers is :7

The distinct number are : 2 3 5 8 7 4 1

Explanation:

The description of the above java code can be given as:

  • In the above java code, a class is defined that is main inside a class-main function is defined in the main function firstly creating a scanner class object that is "ob" then define variables and array that are number, counts and a[].
  • To inserts array elements we use a loop. In the loop, we use integer variable number and define a condition in if block passes a function that check value count total value.
  • In the second loop, we check the condition that array elements value is greater than 0 and print all array elements.
  • The isDistinct function checks in the array two values are not the same. if the values are the same it will return false value because this function is the boolean type that returns an only boolean value.
You might be interested in
ARP only permits address resolution to occur on a single network.could ARP send a request to a remote server in an IP datagram?w
romanna [79]

Answer:

The answer to this question is Yes it is possible

Explanation:

It can be done In the case where a special server is required in each network that would forward the request to the  remote ARP(Address Resolution Protocol) server and will receive the response from the server and send it to the requesting host.So we conclude that we can do that hence the answer is Yes.

5 0
3 years ago
Which is the best tip for optimizing a TrueView video for viewer engagement?
Ivenika [448]

Answer: (A) Look at engagement rate for targeting and focus on the methods with the highest view through rate

Explanation:

TrueView video enables to post ads in social sites however it is paid by the sponsor only if the ad is viewed fully or in some cases it is viewed only upto 30s of the total size of the video.

So in order to have a larger viewer engagement it is necessary for it to focus on the methods which would garner it highest views.

So option A is correct.

Option B and c are not correct these options would not cater to the needs of the viewer.

5 0
3 years ago
What are the four steps of the research process?
pishuonlain [190]

Answer:

Step 1: Identify the Problem

Step 2: Review the Literature. ...

Step 3: Clarify the Problem Step 4: Clearly Define Terms and Concepts.

7 0
2 years ago
Brandon purchased a new processor online as an upgrade. When he purchased the processor, he made sure that it used the same sock
LenaWriter [7]

Answer:

The processor and the motherboard goes bad.

Explanation:

Computer system component upgrade allows the enhancement of the component specification. Every computer system comes with a specific quality, size or speed of its various components like the storage drives size, the memory size, the processor speed and even the software components like the operating system.

An upgrade must be compatible with the system configuration like upgrading the processor. If the upgrade is compatible, the processor speed can be increased, but when an upgrade of the processor is not compatible with the chipsets, this could damage the processor and motherboard.

3 0
3 years ago
No. of
sweet-ann [11.9K]

Answer:

I am very much confused too

Explanation:

There is like no picture or anything to lead up to the question.

3 0
2 years ago
Other questions:
  • Which design element involves the act of lining up objects vertically or horizontally to give a sense of order?
    15·1 answer
  • i see tabs named mowed and Ramsey i tried shredding them and deleting them and ending all the processes but they start duplicati
    13·1 answer
  • Consider the formula: G=D+(A+C^2)*E/(D+B)^3 Show the order that a processor would follow to calculate G. To do so, break down th
    10·1 answer
  • What can be said about the equipment used by photographers during the Civil War?
    13·2 answers
  • Betrand Meyer developed the ______ programming language which is not type-safe because it violates the law of contravariance.
    9·1 answer
  • Eye wash stations should contain enough water to provide ______ minutes of continuous use
    5·2 answers
  • What are two example of ways an electronic record may be distributed to others?
    11·1 answer
  • Which best explains a password attached to a document?
    7·1 answer
  • Please help!! thank you so much!! &lt;3
    14·2 answers
  • How do i unblock a website on a school computer if a school blocks it?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!