Knowee
Questions
Features
Study Tools

Create a database of students using structures, where in each entry of the database will have the following fields:a name, which is a string with at most 128 characterstheir marks in physics, which is an int between 0 and 100their marks in chemistry, which is an int number between 0 and 100their marks in mathematics, which is an int number between 0 and 100You have to output a list of students in the following order.if a student 'A' has lower marks in physics than a student 'B', then A's data is listed before B.If A and B have the same physics marks and A has lower chemistry marks than B, then A is listed before B.If A and B have the same marks in physics and chemistry, and A has lower marks in mathematics than B, then A is listed before B.If all marks are equal and A's name precedes B's name in the dictionary order, then A is listed before B..Input Format :First line contains the number of students n, where 1<=n<=100.In following n lines each line contains(space separated)  a name and their respective marks in physics, chemistry, maths, where 0<=marks<=100.Output Format :Sorted database of n lines.

Question

Create a database of students using structures, where in each entry of the database will have the following fields:a name, which is a string with at most 128 characterstheir marks in physics, which is an int between 0 and 100their marks in chemistry, which is an int number between 0 and 100their marks in mathematics, which is an int number between 0 and 100You have to output a list of students in the following order.if a student 'A' has lower marks in physics than a student 'B', then A's data is listed before B.If A and B have the same physics marks and A has lower chemistry marks than B, then A is listed before B.If A and B have the same marks in physics and chemistry, and A has lower marks in mathematics than B, then A is listed before B.If all marks are equal and A's name precedes B's name in the dictionary order, then A is listed before B..Input Format :First line contains the number of students n, where 1<=n<=100.In following n lines each line contains(space separated)  a name and their respective marks in physics, chemistry, maths, where 0<=marks<=100.Output Format :Sorted database of n lines.

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

This problem can be solved using a programming language like Python. Here's a step-by-step guide on how to do it:

Step 1: Define a structure for the student data. In Python, you can use a dictionary or a class to do this. For simplicity, let's use a dictionary.

student = {
    'name': 'John Doe',
    'physics': 85,
    'chemistry': 90,
    'mathematics': 95
}

Step 2: Create a list of students. Each student is a dictionary like the one defined above.

students = [
    {'name': 'John Doe', 'physics': 85, 'chemistry': 90, 'mathematics': 95},
    {'name': 'Jane Doe', 'physics': 90, 'chemistry': 85, 'mathematics': 90},
    # Add more students as needed
]

Step 3: Define a function to sort the students. This function will use the sorted function in Python, with a custom sorting key. The sorting key is a function that takes a student and returns a tuple. The tuple contains the values that you want to sort by, in the order that you want to sort them.

def sort_students(students):
    return sorted(students, key=lambda student: (student['physics'], student['chemistry'], student['mathematics'], student['name']))

Step 4: Call the sorting function with the list of students.

sorted_students = sort_students(students)

Step 5: Print the sorted list of students.

for student in sorted_students:
    print(student)

This will print the students in the order specified by the problem: first by physics marks, then by chemistry marks, then by mathematics marks, and finally by name. If two students have the same marks in all subjects, the one whose name comes first in alphabetical order will be listed first.

This problem has been solved

Similar Questions

ou are given two tables: Students and Grades. Students contains three columns ID, Name and Marks.Grades contains the following data:Ketty gives Eve a task to generate a report containing three columns: Name, Grade and Mark. Ketty doesn't want the NAMES of those students who received a grade lower than 8. The report must be in descending order by grade -- i.e. higher grades are entered first. If there is more than one student with the same grade (8-10) assigned to them, order those particular students by their name alphabetically. Finally, if the grade is lower than 8, use "NULL" as their name and list them by their grades in descending order. If there is more than one student with the same grade (1-7) assigned to them, order those particular students by their marks in ascending order.Write a query to help Eve.Sample InputSample OutputMaria 10 99Jane 9 81Julia 9 88 Scarlet 8 78NULL 7 63NULL 7 68

You have a database that tracks students in the students table by student_id. The names of the semesters are in a semesters table where the primary key is semester_id. Each semester, students are assigned a grade_point_average which is stored in the grades table. The grades table lists the student_id and the semester_id in addition to the grade_point_average.You need to create a query that finds all the semesters where the student had a grade point average that was less than their average grade point average. You begin typing your query:What should you type in the blank space? (Please type your answer all in lower case. Example: select)

Write a query to display all student details whose sname starts with ‘s’(case sensitive) and is of length between 5 and 20 and squal as ‘undergraduate’(case sensitive). Display the records sorted in ascending order based on sid.

Given 3 tables, students(id, name) , courses(id, name) , grades(id, course_id, student_id, grade), for each student, get all the courses that he/she is enrolled in along with the grade he/she scored for each course. Order the result by the student name in ascending order and if there is a tie, break it with the course name in ascending order and if there is a tie break it with the grade in ascending order. Your query should output a table with the following columns (name, course, grade).

You are developing a Student Record Management System in C. The system needs to store and manage information for multiple students, including their names, roll numbers, and marks obtained in different subjects. Implement array in structures to read, write, and compute average marks and the students scoring above and below the average marks for a class of N students. INPUT/OUTPUT EXAMPLE: Enter the number of students: 3 Enter details for 3 students: Student 1: Name: A Roll Number: 1 Marks in 5 subjects: Subject 1: 12 Subject 2: 13 Subject 3: 14 Subject 4: 15 Subject 5: 16 Student 2: Name: BB Roll Number: 2 Marks in 5 subjects: Subject 1: 11 Subject 2: 13 Subject 3: 12 Subject 4: 15 Subject 5: 14 Student 3: Name: CC Roll Number: 10 Marks in 5 subjects: Subject 1: 13 Subject 2: 14 Subject 3: 16 Subject 4: 17 Subject 5: 11 Class average marks: 13.73 Students scoring above average: A (Roll Number: 1) CC (Roll Number: 10) Students scoring below average: BB (Roll Number: 2)

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.