Using Java:
Create an array with the size of 10 and assign student details (Name, ID, age and TotalMarks) to the array. Perform the Heap Sort to sort the students in ascending order based on their total marks.
Steps:
• Create the student list (use Random class in java to generate the age (15- 25) and total (0-100))
• Print the Student List in a table format
• Perform Heap sort based on the total marks of the students
• Print the Student List after the heap sort in a table format
Plzzzzzzzzzzzzzzzzzz Upvote....
Comment for any queries ....thanks..
Here I attach the code for the program :
package com.journaldev.examples;
import java.util.Random;
class student
{
String name;
int id,age,TotalMarks;
public student(String name, int id, int age, int
TotalMarks) {
this.name = name;
this.id=id;
this.age=age;
this.TotalMarks=TotalMarks;
}
}
public class HelloWorld{
public static void main(String
[]args){
Random random =
new Random();
student [] details = new
student[11];
details[0] = new
student("name1",1,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[1] = new
student("name2",2,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[2] = new
student("name3",3,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[3] = new
student("name4",4,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[4] = new
student("name5",5,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[5] = new
student("name6",6,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[6] = new
student("name7",7,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[7] = new
student("name8",8,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[8] = new
student("name9",9,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
details[9] = new
student("name10",10,(int)(Math.random() * ((25 - 15) + 1)) +
15,random.nextInt(100));
System.out.println("Name ID Age
TotalMarks");
for(int
i=0;i<10;i++)
{
System.out.println(String.format("%s %d %d
%d",details[i].name,details[i].id,details[i].age,details[i].TotalMarks));
}
// sorting the element
int n = 10;
for (int i = 0; i <
n-1; i++)
{
int min_idx = i;
for (int j = i+1; j < n; j++)
if (details[j].TotalMarks < details[min_idx].TotalMarks)
min_idx = j;
details[10] = details[min_idx];
details[min_idx] = details[i];
details[i] = details[10];
}
System.out.println("Sorted
array table: ");
System.out.println("Name ID Age
TotalMarks");
//printing the sorted
array
for(int
i=0;i<10;i++)
{
System.out.println(String.format("%s %d %d
%d",details[i].name,details[i].id,details[i].age,details[i].TotalMarks));
}
}
}
Here I attach screenshot of the program:
Output screenshots::
Using Java: Create an array with the size of 10 and assign student details (Name, ID,...
In Java Create an array of Student objects. Display the students by age in UNSORTED order. Apply the Quick sort and Display the students by age in SORTED order. public class TestQuickStudent { public static void main (String [ ] args ) { /* ***Create your array of Student objects with AT LEAST 5 names */ System.out.println ( " ____________________________"); /* ***LOOP through your array and print out each UNSORTED check by student age */ System.out.println ( " ____________________________");...
Write a C++ program to : Create array arr1 of size 10 Assign values to elements such that - say index = i, arr1[i] = 10 - i. Print arr1 Create arr2 and copy alternate elements from arr1 starting from index 1. Print arr2. Sort arr1 in ascending array and print its elements from indices 3 to 8 Print every output on a different line and separate array elements by spaces.
struct student { char name[10]; int rank; }; Using the student structure given above, create an array of size 5 students.. Then write a complete C program to sort the students array based on the students rank. Use the following sorting techniques in your code. Don’t forget to print initial array and final (sorted) array. a. Selection sort b. Insertion sort c. Merge sort / Quick sort.
Create a java project and create Student class. This class should have the following attributes, name : String age : int id : String gender : String gpa : double and toString() method that returns the Student's detail. Your project should contain a TestStudent class where you get the student's info from user , create student's objects and save them in an arralist. You should save at least 10 student objects in this arraylist using loop statement. Then iterate through...
Write a java code : Student ID at University is composed of year of admission and students number. we aim to implement a structure that improves operations of inserting and searching for a student. To enhance these operations, we will build a tree of linked lists (TreeOfLists) to combine advantages of both structures. Each node in this tree contains a linked list of all students who were admitted in that year. Each node in the linked list represents a student(id,...
QUESTION Create the required java classes to store the students (id, name), the courses (id, title), the exam type (id, name) and the marks for each student. ► Add the necessary methods to; • Store the marks (%) for each student in the course. Search for a course, calculate the averages and display the course details as shown in the example below. Class: Computer Engineering Course Id:222 Course title: DataStructure Student Id Student Name Mid-Term Quiz (10%) Homework (10%) Project...
Must be in Python 3 exercise_2.py # Define the Student class class Student(): # Initialize the object properties def __init__(self, id, name, mark): # TODO # Print the object as an string def __str__(self): return ' - {}, {}, {}'.format(self.id, self.name, self.mark) # Check if the mark of the input student is greater than the student object # The output is either True or False def is_greater_than(self, another_student): # TODO # Sort the student_list # The output is the sorted...
Write a java program that create a 2 dimensional array of type double of size 10 by 10. Fill the array with random numbers using a random number generator. Print the array contents. Write a java program that creates a file called data.txt that uses the PrintWriter class. Write the numbers 1 to 42 into the file. Close the file. Attach both files. Thank you in advance
Create a class with an array of type integer of size 15. Fill the array with random integers of size 1 to 1000. Sort the array. Print out the contents of the array. Thank you in advance
Create an array of size 10 Assign values to the array Print the array Swap the first and last elements in the array Print the array Shift all elements by one to the right Print the array Replace even elements with 0 Replace each element except the first and last by the larger of its two neighbors Print the array