0% found this document useful (0 votes)
10 views

Java Io Java Util Java Lang: Import Import Import

Uploaded by

Ayush Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Java Io Java Util Java Lang: Import Import Import

Uploaded by

Ayush Raj
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

import java.io.

*;
import java.util.*;
import java.lang.*;

class Student
{
private String roll;
private List<Integer> mark;

public Student(String roll,List<Integer> mark)


{
this.roll = roll;
this.mark = mark;
}

public List<Integer> getMarks()


{
return mark;
}

class InvalidNumberException extends Exception


{
public InvalidNumberException(String str)
{
super(str);
}
}

public class Ayush{

public static String getNumber(int num) throws InvalidNumberException


{
if(num>30 && num<0)
{
throw new InvalidNumberException("Invalid Input");
}
else
{
return "Valid Input";
}
}

public static void main(String args[])


{
try{
List<Student> values = Arrays.asList
(
new Student ("10001",Arrays.asList(16,18,18,17,16,16)),
new Student ("10002",Arrays.asList(20,20,19,19,19,17)),
new Student ("10003",Arrays.asList(20,17,18,19,20,20)),
new Student ("10004",Arrays.asList(13,19,11,13,16,19)),
new Student("10005",Arrays.asList(11,18,9,0,16,16)),
new Student("10006",Arrays.asList(17,20,19,13,18,16)),
new Student("10007",Arrays.asList(15,20,17,13,14,17))
);

}
catch(InvalidNumberException e)
{
System.out.println(e.toString());
}

values.stream().forEach(System.out::println);

System.out.println(values.stream()
.mapToLong(e -> e.getMarks.stream()
.filter(e -> e>15)
.toList()
).toList()
);

System.out.println(values.stream()
.mapToLong(e -> e.getMarks.stream()
.filter(e -> e.equals())
.mapToInteger(x ->x.average())
).toList()
);

System.out.println(values.stream()
.mapToLong(e -> e.getMarks.stream()
.mapToInteger(e -> (e*100)/30)
.toList()

)
);

}
}

You might also like