What's new
Pinoy Internet and Technology Forums
Take a moment to sign up and gain unlimited access and extra privileges that guests are not entitled to. Registration is quick, simple and absolutely free. Join our community today!

HELP MGA MASTER! JAVA

EMG

Elite
Joined
Jun 24, 2018
Posts
628
Reaction
404
Age
22
1626932036642.png



1626932056447.png
 

Attachments

PHC_Jayvee

.
Contributor
loop mo lang yan

loop You do not have permission to view the full content of this post. Log in or register now.

if even / odd You do not have permission to view the full content of this post. Log in or register now.

sa 2nd

loop lang din

tas gawa ka variable lowest and highest

tas sa highest

if number now is > number stored
--- set mo yung var to number now

same sa lowenst
 
Pa-test nalang din po, then paki check na din ng array.
Problem 1:
public class Main {
    public static void main(String[] args) {
        int[] field = {2, 20, 3, 13, 15, 3, 9, 10, 1, 5, 8};
        int oddCount = 0;
        for(int e : field)
            if(e % 2 != 0)
                oddCount++;
        System.out.println("Odd Numbers Count: " + oddCount);
    }
}
 
Last edited:
Problem 2:
public class Main {
    public static void main(String[] args) {
        int[] field = {2, 20, 3, 13, 15, 3, 9, 10, 1, 5, 8};
        bubbleSort(field);
        System.out.println("Max Number in Field " + field[field.length-1]);
        System.out.println("Min Number in Field " + field[0]);
    }
  
static int[] bubbleSort(int[] array){
    for(int i = 0; i < array.length; i++){
        for(int j = 0; j < array.length - 1; j++){
            if(array[j] > array[j + 1]){
                int temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }
        }
    }
    return array;
}
}
 

Online statistics

Members online
1,867
Guests online
1,288
Total visitors
3,155

Forum statistics

Threads
1,138,869
Posts
18,820,484
Members
1,551,339
Attachments
1,512,041
Profile posts
98,869
Top