Computer Science, asked by Ayush0009, 1 year ago

You can get more than 50 points.
Please do this java program.
It's urgent.

Attachments:

Answers

Answered by nilesh102
1

Hi mate,

Answer: Java is a programming language that developers use to create applications on your computer. Chances are you've downloaded a program that required the Java runtime, and so you probably have it installed it on your system. Java also has a web plug-in that allows you to run these apps in your browser.

The basic steps to create the Hello World program are: write the program in Java, compile the source code, and run the program.

Write the Java Source Code. ...

Save the File. ...

Open a Terminal Window. ...

The Java Compiler. ...

Change the Directory. ...

Compile Your Program. ...

Run the Program.

The Java collections framework provides various algorithms that can be used to manipulate elements stored in data structures.

Algorithms in Java are static methods that can be used to perform various operations on collections.

Since algorithms can be used on various collections, these are also known as generic algorithms.

Let's see the implementation of different methods available in the collections framework.

1. Sorting Using sort()

The sort() method provided by the collections framework is used to sort elements. For example,

Search Programiz

Java Algorithms

Java Algorithms

In this tutorial, we will learn about different algorithms provided by the Java collections framework with the help of examples.

The Java collections framework provides various algorithms that can be used to manipulate elements stored in data structures.

Algorithms in Java are static methods that can be used to perform various operations on collections.

Since algorithms can be used on various collections, these are also known as generic algorithms.

Let's see the implementation of different methods available in the collections framework.

1. Sorting Using sort()

The sort() method provided by the collections framework is used to sort elements. For example,

import java.util.ArrayList;

import java.util.Collections;

class Main {

public static void main(String[] args) {

// Creating an array list

ArrayList<Integer> numbers = new ArrayList<>();

// Add elements

numbers.add(4);

numbers.add(2);

numbers.add(3);

System.out.println("Unsorted ArrayList: " + numbers);

// Using the sort() method

Collections.sort(numbers);

System.out.println("Sorted ArrayList: " + numbers);

}

}

Output

Unsorted ArrayList: [4, 2, 3]

Sorted ArrayList: [2, 3, 4]

Here the sorting occurs in natural order (ascending order). However, we can customize the sorting order of the sort() method using the Comparator interface.

2. Shuffling Using shuffle()

The shuffle() method of the Java collections framework is used to destroy any kind of order present in the data structure. It does just the opposite of the sorting. For example,

import java.util.ArrayList;

import java.util.Collections;

class Main {

public static void main(String[] args) {

// Creating an array list

ArrayList<Integer> numbers = new ArrayList<>();

// Add elements

numbers.add(1);

numbers.add(2);

numbers.add(3);

System.out.println("Sorted ArrayList: " + numbers);

// Using the shuffle() method

Collections.shuffle(numbers);

System.out.println("ArrayList using shuffle: " + numbers);

}

}

Output

Sorted ArrayList: [1, 2, 3]

ArrayList using shuffle: [2, 1, 3]

When we run the program, the shuffle() method will return a random output.

i hope it helps you..

Answered by HariesRam
15

Input :

  1. import java.util.Scanner;
  2. public class Student_Marks
  3. {
  4. public static void main(String[] args)
  5. {
  6. int n, total = 0, percentage;
  7. Scanner s = new Scanner(System.in);
  8. System.out.print("Enter no. of subject:");
  9. n = s.nextInt();
  10. int marks[] = new int[n];
  11. System.out.println("Enter marks out of 100:");
  12. for(int i = 0; i < n; i++)
  13. {
  14. marks[i] = s.nextInt();
  15. total = total + marks[i];
  16. }
  17. percentage = total / n;
  18. System.out.println("Sum:"+total);
  19. System.out.println("Percentage:"+percentage);
  20. }
  21. }

Output:

$ javac Student_Marks.java

$ java Student_Marks

Enter no. of subject:5

Enter marks out of 100:

86

89

91

82

78

Sum:426

Percentage:85

❤️

Similar questions
Math, 6 months ago