The problem wants me to have the output of comparing value of 2 array sets and store the largest value to array 3.
Right now this what I have coded
import java.lang.Math.*;
public class loopers1
{
public static void main(String args[])
{
int x,larg=0,smol=100;
int genArray1[] = new int[10];
int genArray2[] = new int[10];
for(x = 0; x<=9; x++) {
genArray1[x] = 1 + (int)(Math.random()*99);
genArray2[x] = 1 + (int)(Math.random()*99);
if (genArray1[x]==genArray2[x]){
System.out.print("same output");
}else
System.out.print("not the same output");
if(genArray1[x] < larg){
larg =genArray1[x];
}else
if(genArray2[x]< larg){
larg =genArray2[x];
}
}
for(x = 0; x<=9; x++)
System.out.println("\nLargest value in the array "+larg);
System.exit(0);
}
}
Aucun commentaire:
Enregistrer un commentaire