DEV Community

Neelakandan R
Neelakandan R

Posted on

2 1 1 1

array mark ,equal mark,small mark,highest mark, second highest mark

Program 1:

package afterfeb13;

public class secondgreater {
    public static void main(String[] args) {
        int[] mark = { 200, 100, 78, 89, 102 };
        int highest = 0, second_highest = 0, third_highest = 0;
        for (int i = 0; i < mark.length; i++) {
            if (mark[i] > highest)// 56>0//100>56---//102>100
            {
                second_highest = highest;
                highest = mark[i];

            } else if (mark[i] > second_highest) {
                third_highest = second_highest;
                second_highest = mark[i];
            } else if (mark[i] > third_highest) {
                third_highest = mark[i];
            }

        }

        System.out.println("highest num = " + highest);
        System.out.println("second_highest = " + second_highest);
        System.out.println("third_highest = " + third_highest);

    }

}

Enter fullscreen mode Exit fullscreen mode

Output:

highest num = 200
second_highest = 102
third_highest = 100

Program 2:

package afterfeb13;

public class smallestnum {
    public static void main(String[] args) {
        int[] mark = { 200, 100, 78, 89, 102 };
        int small = mark[0];
        for (int i = 0; i < mark.length; i++) {
            if (mark[i] < small) {
                small = mark[i];
            }
        }
        System.out.println(small);

    }
}
Enter fullscreen mode Exit fullscreen mode

Output:
78

Program 3:

package afterfeb13;

public class numberequal {
    public static void main(String[] args) {
        int[] mark = { 90, 81, 82, 90, 90 };
        String[]subject= {"tamil","english","maths","social","science"};
        int count = 0;
        for (int i = 0; i < mark.length; i++)
            if (mark[i] == 90) {
                System.out.println(subject[i]+"="+mark[i]);
                count++;
            }
        System.out.println("count = " + count);

    }

}


Enter fullscreen mode Exit fullscreen mode

Output:
tamil=90
social=90
science=90
count = 3

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay