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
Write code to define a function named mymath. The function has three arguments in the following order: Boolean, Integer, and Int
saveliy_v [14]

Answer:

public class Main

{

public static void main(String[] args) {

Main m=new Main();

System.out.println(m.mymath(true,5,2)); // calling the function mymath

}

public int mymath(boolean a,int b,int c) // mymath function definition

{

if(a==true)

{

int d=b+c;

return d;

}

else{int e=b-c;

return e;

}

}

}

7 0
2 years ago
What is client server relationship is the basic form of what
stepan [7]

computer network is the answer                          

8 0
3 years ago
After a normal system shutdown, when the computer is turned off, contents of the memory used to store bios settings are
kiruha [24]
The settings are retained

<span>Technically, Bios software is stored in a non-volatile ROM (Read-Only Memory) chip found on the motherboard.  Usually, this kind of chip retains its contents even after a normal system shutdown. Rom chips contains programs that are collectively referred to as BIOS chip or Basic Input/Output Services</span>
8 0
3 years ago
Read 2 more answers
How do you measure the capacity of speed and memory of computer system<br>Explain.​
jeka94
Im sorry i just need points
3 0
3 years ago
I need help with the stalk holders project
anygoal [31]

Answer:

A project is successful when it achieves its objectives and meets or exceeds the expectations of the stake­holders. But who are the stakeholders? Stakeholders are individuals who either care about or have a vested interest in your project. They are the people who are actively involved with the work of the project or have something to either gain or lose as a result of the project. When you manage a project to add lanes to a highway, motorists are stakeholders who are positively affected. However, you negatively affect residents who live near the highway during your project (with construction noise) and after your project with far-reaching implications (increased traffic noise and pollution).

Explanation:

6 0
3 years ago
Other questions:
  • HELLLLLP ill make you brainiest and ill give u a lot of points if you HELP ME Directions Part One.
    12·2 answers
  • . Given an initially empty stack s that accepts integers, the following operations are performed: s.push (10) s.push (20) s.push
    13·1 answer
  • Cloud resources are​ ________ because many different organizations use the same physical hardware.
    12·1 answer
  • Any parameter that receives a value and also sends a value outside the function must be declared as a reference parameter.
    8·1 answer
  • In which circumstances would the view side by side feature be useful or helpful.
    15·2 answers
  • Explain why it is not necessary for a program to Explain why it is not necessary for a program to be completely free of defects
    13·1 answer
  • Consider Statement 1: All prime numbers greater than 3 are equal to a multiple of six, plus 1 or minus 1. Let P(x) be the statem
    7·1 answer
  • You can insert video by clicking video drop-down menu on the ______ tab.
    15·1 answer
  • In Outlook 2016, the Tell Me function can be accessed by
    15·2 answers
  • What is the suffix of hollow?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!