Menu
Question Index
...


Write a program to get possible combinations of marks of a student.
Note: Given the total marks and he failed in only one subject, and got distinction in only one subject. Assume that number of subjects is 3, maximum marks per subject is 10, fail marks is less than or equal to 3 and distinction is greater than or equal to 8.

Input (Integer) Output(List)
18 [[1-7-10], [1-10-7], [2-6-10], [2-7-9], [2-9-7], [2-10-6], [3-5-10], [3-6-9], [3-7-8], [3-8-7], [3-9-6], [3-10-5], [5-3-10], [5-10-3], [6-2-10], [6-3-9], [6-9-3], [6-10-2], [7-1-10], [7-2-9], [7-3-8], [7-8-3], [7-9-2], [7-10-1], [8-3-7], [8-7-3], [9-2-7], [9-3-6], [9-6-3], [9-7-2], [10-1-7], [10-2-6], [10-3-5], [10-5-3], [10-6-2], [10-7-1]]
13 [[0-4-9], [0-5-8], [0-8-5], [0-9-4], [1-4-8], [1-8-4], [4-0-9], [4-1-8], [4-8-1], [4-9-0], [5-0-8], [5-8-0], [8-0-5], [8-1-4], [8-4-1], [8-5-0], [9-0-4], [9-4-0]]
20 [[3-7-10], [3-10-7], [7-3-10], [7-10-3], [10-3-7], [10-7-3]]
12 [[0-4-8], [0-8-4], [4-0-8], [4-8-0], [8-0-4], [8-4-0]]
25 []

class GetPossibleMarksWithOneFailAndOneDistinction

{    public static void main(String s[])
    {
        System.out.println("List of possible marks : ");
        ArrayList output = getPossibileMarks(13);
        System.out.println(output);

    }


public static ArrayList<Marks> getPossibileMarks(int totalMarks) {
//Write code here to get the list of possible marks of a student
}

//If required, write any additional methods here
}
class Marks {

int subject1;
int subject2;
int subject3;

Marks(int subject1, int subject2, int subject3) {
this.subject1 = subject1;
this.subject2 = subject2;
this.subject3 = subject3;
}

@Override
public String toString() {
return "[" + subject1 + "-" + subject2 + "-" + subject3 + "]";
}
}

Doubts

Problems

Topic: Java ArrayList

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App