Computer Science

posted by .

//program that puts two lists in order in one single list with all the numbers in order

import java.util.Scanner;
public class listOrder {
public static void main (String [] args){
int [] list1;
int [] list2;
int [] list3;
int temp;

list1 = new int [10];
list2 = new int [10];
list3 = new int [20];

for (int i = 0; i < 10; i++)
{
list1[i] = (int) (Math.random () * 100)+1;
}

for (int j = 0; j < 10; j++)
{
for (int i = 0; i < 10; i++)
{
if (list1[i] > list1[j])
{
temp = list1[i];
list1[i] = list1[j];
list1[j] = temp;
}
}
}
for (int i = 0; i < 10; i++)
{
System.out.print(" list1[" + i + "] = " + list1[i] + " / ");
}

System.out.println (" ");

for (int i = 0; i < 10; i++)
{
list2[i] = (int) (Math.random () * 100)+1;
}
for (int j = 0; j < 10; j++)
{
for (int i = 0; i < 10; i++)
{
if (list2[i] > list2[j] )
{
temp = list2[i];
list2[i] = list2[j];
list2[j] = temp;
}
}
}

so i got these two lists... how do i join them in list3[]?

they are already worked in a way so the get in order from least to greatest...

list3 will have the numbers from list1 and list2, joined will be 20 numbers....

plz help me, thanks

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. Java help please

    I am trying to run the following program and am getting this error: java.util.InputMismatchException import java.io.*; import java.util.*; public class Pre2 { static Scanner console = new Scanner(System.in); public static void main(String[] …
  2. Computers

    //program that puts two lists in order in one single list with all the numbers in order import java.util.Scanner; public class listOrder { public static void main (String [] args){ int [] list1; int [] list2; int [] list3; int temp; …
  3. Computer Science-Java

    Hi, I am writing an application class for a Lunar Calendar I created in a service class and I have to make sure it is able to detect that the year entered is not in the range of values(I have done this in the service class using a …
  4. Java Panel Problem

    I am supose to draw a grid and center it with a 10 pix border all the way around it. I have done this but no matter what I do I cannot get a 10 pix border. Here is my code. You will notice i have added 20 to the setsize param to account …
  5. Computer Science Computer Programming

    Please help! I cannot figure out what I am doing wrong. I cannot get the correct output when I run the system. Here is what I have entered in to Netbeans IDE: package shippingcharges; public class ShippingCharges { private double weight; …
  6. computer science

    Im trying to create an arraylist that's sorted but I have no idea how to sort the numbers. I cant use the array.sort method here is my code: public class Testing { private int [] data; private int count; private static int defCapacity …
  7. Computer Science

    I posted this question before. The assignment was: write a Java method if the first parameter is less than the second parameter add the two and print the result ten times. How do I write the result 10 times as a loop?
  8. Computer Programming

    I already posted this question but I gave it a try I'm not sure if I'm on the right track: Make a util class with three methods. First method's name is add, that returns the result by adding two numbers. Second method's name is multiply, …
  9. Java programming

    Okay so I am rewrite the program and it's still not coming right can anyone help me see what's going wrong here please I have to turn this in by tmw so here the program The following program is supposed to read two numbers from a file …
  10. Java programming

    Hi, I'm trying to figure out how to implement toString() methods into the JavaTest and H2ClassB classes so that the output would be 4 3 7 5 99 3: import java.util.ArrayList; public class JavaTest { ArrayList <JavaTest> list = …

More Similar Questions