Description
1. Make a student class with attributes roll number and name (single word only). Read input from the console and print details on the console. The input first consists of the number of test cases, then each test case has two strings, roll number and name.
Sample Input
2
IIT2017001 Naga
IIT2017002 Ajay
Sample Output
IIT2017001 Naga
IIT2017002 Ajay
2. A class consists of an array of students. Read all student details in a class. Sort the class roll number wise. Print the class sorted as per roll number. The first input is the number of test cases, with each test case followed by the number of students and details of all students. You should write your own sorting algorithm and not use the collection framework sorting utilities.
Sample Input
1
2
IIT2017002 Ajay
IIT2017001 Naga
Sample Output
IIT2017001 Naga
IIT2017002 Ajay
1
3 5 2
RSI2017002 Haider
RSI2016001 Vaibhav
RSI2016504 Lhilo IIT2017005 Aditya
IIT2017003 Chandan
IIT2017001 Naga
IIT2017002 Ajay
IIT2017004 Paul
Sample Output
IIT2017001 Naga RSI2017002 Haider
IIT2017002 Ajay RSI2017002 Haider
IIT2017003 Chandan RSI2016001 Vaibhav
IIT2017004 Paul RSI2016001 Vaibhav
IIT2017005 Aditya RSI2016504 Lhilo
1
3 5 2
RSI2017002 Haider
RSI2016001 Vaibhav
RSI2016504 Lhilo IIT2017005 Aditya
IIT2017003 Chandan
IIT2017001 Naga
IIT2017002 Ajay
IIT2017004 Paul
Sample Output
IIT2017001 Naga RSI2017002 Haider
IIT2017002 Ajay RSI2017002 Haider
IIT2017003 Chandan RSI2016001 Vaibhav
IIT2017004 Paul RSI2016001 Vaibhav
IIT2017005 Aditya RSI2016504 Lhilo
RSI2017002 Haider
IIT2017001 Naga
IIT2017002 Ajay
RSI2016001 Vaibhav
IIT2017003 Chandan
IIT2017004 Paul
RSI2016504 Lhilo
IIT2017005 Aditya
Explanation: Locate the line “RSI2017002 Haider” in the same output. The part before this line is from the previous question while the part after this line is another view of the same information.
5. A student attempts numerous assignments and gets marks for the different assignments. In question 2, the student details are followed by the assignment details. Print the total marks obtained by each student in addition. The first input is the number of test cases, with each test case followed by the number of students and details of all students. Thereafter the next input is the number of assignments a. For each assignment, the first input is the number of students who attempted the assignment, followed by the roll number and marks scored by each student in the assignment. If there are no marks associated with a student for an assignment, the student is considered absent and marked as 0.
Sample Input
Number of test cases 1
Number of students 2
Student list IIT2017002 Ajay IIT2017001 Naga
Number of assignments 3
Assignment 1, number of students Assignment 1, mark list 2
IIT2017001 3
IIT2017002 2
Assignment 2, number of students Assignment 1, mark list 2
IIT2017002 1
IIT2017001 1
Assignment 2, number of students Assignment 1, mark list 1
IIT2017002 3
Sample Output
IIT2017001 Naga 4
IIT2017002 Ajay 6
Explanation:
IIT2017001 Naga (3 in assignment 1, 1 in assignment 2)
IIT2017002 Ajay (2 in assignment 1, 1 in assignment 2, 3 in assignment 3)
Reviews
There are no reviews yet.