Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class myArray{
- public static void main (String[]args){
- boolean error = true;
- int[] myArray=new int [15];
- for(int i =0;i<myArray.length-1;i++){
- double r = Math.random()*100;
- myArray[i] = (int)r;
- System.out.print(myArray[i]+", ");
- }
- System.out.println();
- for(int i =0;i<myArray.length-1;i++){
- if(myArray[i]>myArray[myArray.length-1]){//Why does this not work?
- System.out.print(myArray[i]+", ");
- error = false;
- }
- }
- if(error == true){System.out.println("the last number is the largest");}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement