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
Nookie1986 [14]
3 years ago
15

Java programming

Computers and Technology
1 answer:
Marat540 [252]3 years ago
5 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main {

public static void removeDuplicate(ArrayList<Integer> list){

 ArrayList<Integer> newList = new ArrayList<Integer>();

 for (int num : list) {

  if (!newList.contains(num)) {

   newList.add(num);  }  }

 for (int num : newList) {

     System.out.print(num+" ");  } }

public static void main(String args[]){

 Scanner input = new Scanner(System.in);

 ArrayList<Integer> list = new ArrayList<Integer>();

 System.out.print("Enter ten integers: ");

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

     list.add(input.nextInt());  }

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

 removeDuplicate(list);

}}

Explanation:

This defines the removeDuplicate function

public static void removeDuplicate(ArrayList<Integer> list){

This creates a new array list

 ArrayList<Integer> newList = new ArrayList<Integer>();

This iterates through the original list

 for (int num : list) {

This checks if the new list contains an item of the original list

  if (!newList.contains(num)) {

If no, the item is added to the new list

   newList.add(num);  }  }

This iterates through the new list

 for (int num : newList) {

This prints every element of the new list (At this point, the duplicates have been removed)

     System.out.print(num+" ");  } }

The main (i.e. test case begins here)

public static void main(String args[]){

 Scanner input = new Scanner(System.in);

This declares the array list

 ArrayList<Integer> list = new ArrayList<Integer>();

This prompts the user for ten integers

 System.out.print("Enter ten integers: ");

The following loop gets input for the array list

<em>  for(int i = 0; i<10;i++){ </em>

<em>      list.add(input.nextInt());  } </em>

This prints the output header

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

This calls the function to remove the duplicates

 removeDuplicate(list);

}}

You might be interested in
A web designer is creating a web site and wants each browser to resize the text size to look the same in each device. what measu
adelina 88 [10]
The designer could use the measurements in pixels. 
4 0
3 years ago
Write a program that asks the user to input a set of floating-point values. When the user enters a value that is not a number, g
Lady_Fox [76]

Answer:

Check the explanation

Explanation:

// include the necessary packages

import java.io.*;

import java.util.*;

// Declare a class

public class DataReader

{

// Start the main method.

public static void main(String[] args)

{

// create the object of scanner class.

Scanner scan = new Scanner(System.in);

// Declare variables.

boolean done = false;

boolean done1 = false;

float sum = 0;

double v;

int count = 0;

// start the while loop

while (!done1)

{

// start the do while loop

do

{

// prompt the user to enter the value.

System.out.println("Value:");

// start the try block

try

{

// input number

v = scan.nextDouble();

// calculate the sum

sum = (float) (sum + v);

}

// start the catch block

catch (Exception nfe)

{

// input a character variable(\n)

String ch = scan.nextLine();

// display the statement.

System.out.println(

"Input Error. Try again.");

// count the value.

count++;

break;

}

}

// end do while loop

while (!done);

// Check whether the value of count

// greater than 2 or not.

if (count >= 2)

{

// display the statement on console.

System.out.println("Sum: " + sum);

done1 = true;

}

}

}

}

Sample Output:

Value:

12

Value:

12

Value:

ten

Input Error. Try again.

Value:

5

Value:

nine

Input Error. Try again.

Sum: 29.0

3 0
3 years ago
Read 2 more answers
Francis has applied for admission to a computer science program, and one of the requirements for admission is the completion of
Nataly_w [17]

Answer:

an aptitude test.

Explanation:

Based on the scenario being described it can be said that the test that Francis is scheduled to take would be classified as an aptitude test. This is a test that tries to determine an individual's innate ability at a particular competency. These are abilities such as sequencing skills and abstract reasoning skills, and are the results of these tests are used in order to see where a candidate can best be placed within a program/company to best perform.

8 0
3 years ago
Read 2 more answers
Which statement compares the copy and cut commands?
ella [17]

Answer: duplicate

Explanation:

5 0
3 years ago
Read 2 more answers
100 POINTS + BRAINLYEST FOR FIRST PERSON THAT GETS IT RIGHT!!!! While writing a formula, what are some ways to insert a cell ref
nexus9112 [7]

Answer:

Line second and third i.e, "typing the cell name, like "B4"  and clicking the cell to reference " the correct answer.

Explanation:

It relates to some kind of set of cells on the worksheet, which could be used to calculates the formula. It also helps to locate the information, which you want to analyze in the calculation. It can also provide the cell reference in  more than one formula in the same worksheet, that relates to Information on many other workbooks, and wrong choices can be described as follows:

  • Hovering provides the basic details, in which we hover, that's why it is wrong .
  • Zooming is used in projection, it can't be used in the cell reference, that's why it is wrong.
7 0
3 years ago
Read 2 more answers
Other questions:
  • A school librarian has been asked to identify inappropriate Internet usage. Which students would most likely be reported to the
    5·2 answers
  • Llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll
    7·1 answer
  • An accompanying ____ gives audience members reference notes and review material for your presentation.
    6·1 answer
  • ________ of Willa Catha present an unadorned picture oflife on the prairies of the Midwestern United States during the19th centu
    8·1 answer
  • What did Adam and Eve look like?
    7·2 answers
  • Looking for friends, anyone up for it?
    12·2 answers
  • Site at least 3 articles of impact of internet that affect in our daily lives.
    15·1 answer
  • Select the correct answer from each drop-down menu. The following diagram shows four resistors. What is the effective resistance
    9·1 answer
  • Evaluate and compare free and commercial versions of the Avast antivirus software
    6·1 answer
  • What is the main advantage of using DHCP?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!