Menu
Question Index
...


Write a program to get the possible combinations of marks of a student.
Note: Given the total marks and he did not fail in any subject, and got distinction in atleast 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 [[4-4-10], [4-5-9], [4-6-8], [4-8-6], [4-9-5], [4-10-4], [5-4-9], [5-5-8], [5-8-5], [5-9-4], [6-4-8], [6-8-4], [8-4-6], [8-5-5], [8-6-4], [9-4-5], [9-5-4], [10-4-4]]
20 [[4-6-10], [4-7-9], [4-8-8], [4-9-7], [4-10-6], [5-5-10], [5-6-9], [5-7-8], [5-8-7], [5-9-6], [5-10-5], [6-4-10], [6-5-9], [6-6-8], [6-8-6], [6-9-5], [6-10-4], [7-4-9], [7-5-8], [7-8-5], [7-9-4], [8-4-8], [8-5-7], [8-6-6], [8-7-5], [8-8-4], [9-4-7], [9-5-6], [9-6-5], [9-7-4], [10-4-6], [10-5-5], [10-6-4]]
17 [[4-4-9], [4-5-8], [4-8-5], [4-9-4], [5-4-8], [5-8-4], [8-4-5], [8-5-4], [9-4-4]]
27 [[7-10-10], [8-9-10], [8-10-9], [9-8-10], [9-9-9], [9-10-8], [10-7-10], [10-8-9], [10-9-8], [10-10-7]]
30 [[10-10-10]]
15 []

class GetPossibleMarksWithAtleastOneDistinction

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

    }


public static ArrayList 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