Write a Java program to create a Package “SY” which has a class SYMarks (members – ComputerTotal, MathsTotal, and ElectronicsTotal). Create another package TY which has a class TYMarks (members – Theory, Practicals). Create n objects of Student class (having rollNumber, name, SYMarks and TYMarks). Add the marks of SY and TY computer subjects and calculate the Grade (‘A’ for >= 70, ‘B’ for >= 60 ‘C’ for >= 50 , Pass Class for > =40 else ‘FAIL’) and display the result of the student in proper format.
package SY;
import java.io.*;
import java.util.*;
public class syclass
{
public int ct,mt,et;
public void getdata()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the total marks of computer,Maths,Electronic subject
outoff 200");
ct=sc.nextInt();
mt=sc.nextInt();
et=sc.nextInt();
}
}
// Create package of TY (tyclass.java)
package TY;
import java.io.*;
import java.util.*;
public class tyclass
{
public int th,prac;
public void getdata()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the total marks of theory outoff 400 and Practical outoff 200 ");
th=sc.nextInt();
prac=sc.nextInt();
}
}
// Main Program
import SY.*;
import TY.*;
import java.io.*;
import java.util.*;
class studinfo
{
public int rno,syt,tyt,gt;
public float per;
public String name,grade;
public void getdata()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the roll number and name of student");
rno=sc.nextInt();
name=sc.next();
}
}
class studentmarks
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int n,i,j;
System.out.println("How many student you want");
n=sc.nextInt();
syclass s[]=new syclass[n];
tyclass t[]=new tyclass[n];
studinfo si[]=new studinfo[n];
for(i=0;i<n;i++)
{
si[i]=new studinfo();
s[i]=new syclass();
t[i]=new tyclass();
si[i].getdata();
s[i].getdata();
t[i].getdata();
si[i].syt=s[i].ct+s[i].mt+s[i].et;
si[i].tyt=t[i].th+t[i].prac;
si[i].gt=si[i].syt+si[i].tyt;
si[i].per= si[i].gt/13;
if(si[i].per>=70)
si[i].grade="A";
else if(si[i].per>=60)
si[i].grade="B";
else if(si[i].per>=50)
si[i].grade="C";
else if(si[i].per>=40)
si[i].grade="PASS";
else
si[i].grade="Fail";
}
System.out.println("RNo \t Name \t SYT \t TYT \t GT \t Per \t Grade");
for(i=0;i<n;i++)
{
System.out.println(si[i].rno +" \t"+si[i].name+" \t"+si[i].syt+"
\t"+si[i].tyt+" \t"+si[i].gt+" \t"+si[i].per+" \t"+si[i].grade);
}
}
}
0 Comments