S 14
S 14
import java.io.*;
class PrimeNumber {
int a;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrimeNumber() {
try {
System.out.print("Enter any integer to check prime: ");
a = Integer.parseInt(br.readLine());
if (a == 0)
throw new NumberZeroException();
else
prime();
} catch (NumberZeroException ex) {
System.out.println(ex);
} catch (IOException ex1) {
System.out.println("Enter proper number");
}
}
//***************************************************************************
package SY;
import java.util.Scanner;
public SYMarks(){
System.out.print("Enter Computer total marks: ");
ComputerTotal = sc.nextDouble();
System.out.print("Enter Maths total marks: ");
MathsTotal = sc.nextDouble();
System.out.print("Enter Electronics total marks: ");
ElectronicsTotal = sc.nextDouble();
sytotal = (ComputerTotal + MathsTotal + ElectronicsTotal) / 3;
}
package TY;
import java.util.Scanner;
public TYMarks(){
System.out.print("Enter theory marks: ");
Theory = sc.nextDouble();
System.out.print("Enter practicals marks: ");
Practicals = sc.nextDouble();
tytotal = (Theory + Practicals)/2;
}
import java.util.Scanner;
import SY.SYMarks;
import TY.TYMarks;
void display() {
System.out.println("Roll number: " + rollNumber);
System.out.println("Name: " + name);
sy.display();
ty.display();
System.out.println("Your final grade is: " + grade);
}
void grade() {
total = (sy.sytotal + ty.tytotal) / 2;
if (total>=70)
grade = 'A';
else if(total >= 60)
grade = 'B';
else if(total >= 50)
grade = 'C';
else if(total >= 40)
grade = 'D';
else
grade = 'F';
}
public static void main(String[] args) {
int i, n, rno;
String name;
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of students: ");
n = sc.nextInt();
Stud s[] = new Stud[n];
for(i=0;i<n;i++) {
System.out.println("\nEnter student " + (i+1) + " details-->");
System.out.print("Enter roll no: ");
rno = sc.nextInt();
System.out.print("Enter name: ");
name = sc.next();
s[i] = new Stud(rno,name);
}
for(i=0;i<n;i++) {
System.out.println("\nStudent " + (i+1) + "Details");
s[i].display();
}
}
}