Menu
Topics Index
...
`

Print the possible marks of a student


If you need explanation Read this topic

If you need Answer Take test on this topic

Write a program to print the possible combinations of marks of a student given the total marks.
Note: Assume he did not fail in any subject and did not get distinction in any 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 (Printed Output)
18 4 7 7
5 6 7
5 7 6
6 5 7
6 6 6
6 7 5
7 4 7
7 5 6
7 6 5
7 7 4
20 6 7 7
7 6 7
7 7 6
12 4 4 4
15 4 4 7
4 5 6
4 6 5
4 7 4
5 4 6
5 5 5
5 6 4
6 4 5
6 5 4
7 4 4
21 7 7 7



class PrintPossibleMarks
{
    public static void main(String s[])
    {
        System.out.println("Possible marks of the student : ");
        printPossibleMarks(18);

    }


    public static void printPossibleMarks(int totalMarks) {
    }

}
Topic: Nested for Loop In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

As per the program, we need to print the marks for 3 exams which are between 4 and 7...
For this we need to take 3 nested loops iterates through 4 to 7... outer for loop for first subject and first inner for loop for second subject and inner most for loop is for third subject... we need to print the marks of 3 subjects only if sum of all the 3 subjects are equal to the total...

Posted by Gopinath Manchikanti    2015-02-20 06:12:35


*here we need to use three nested loop to calculate the sum
three loops for the each subject here we need to travel from 4 to 7 bcz students did not get failed or did not get disctinction
* in the inner most loop cal the sum of the s1+s2+s3 if the sum is =totalMarks than print the values of the s1 s2 s3 with the spaces

Posted by Uday Kumar    2015-02-23 03:29:16


This dose is now closed and the winners are Gopinath Manchikanti,  for 'First Correct Comment', Uday Kumar,  for 'Second Correct Comment'. The 'lucky liker' is Gopinath Manchikanti. Please login into Merit Campus using facebook, to claim your recharge. Go to http://java.meritcampus.com/earnings to raise the recharge.

Posted by Merit Campus    2015-02-24 04:54:54


© meritcampus 2019

All Rights Reserved.

Open In App