Space for google add

Write a Java program to create a Package “SY” and "TY".

    


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.


SYMarks.java

package SY;

import java.io.*;

import java.util.*;

public class SYMarks

{

int ComT,MathT,ElecT;

public  void accept()

{ Scanner s=new Scanner(System.in);

System.out.println("Enter ComputerTotal,MathTotal,ElectronicsTotal :");

ComT=s.nextInt();

MathT=s.nextInt();

ElecT=s.nextInt();

public void display()

{

System.out.println("ComputerTotal :"+ComT);

System.out.println("MathTotal :"+MathT);

System.out.println("ElectronicsTotal :"+ElecT);

}

public int  total()

{

return (ComT+MathT+ElecT);

}

}



SYMarks.java

package TY;

import java.util.*;

import java.io.*;

public class TYMarks

{

int theory,practical;

public void accept()

{ Scanner s=new Scanner(System.in);

System.out.println("Enter theory and pactical marks :");

theory=s.nextInt();

practical=s.nextInt();

public void display()

{

System.out.println("Theory Marks :"+theory);

System.out.println("Practical Marks :"+practical);

}

public int total()

{

return (theory+practical);

}

}



student.java 

import SY.SYMarks;

import TY.TYMarks;

import java.util.*;


 class student1

{

int r;

String n;

SYMarks s1;

TYMarks t1;

public void accept()

{

Scanner s=new Scanner(System.in);

System.out.println("Enter roll number.");

r=s.nextInt();


System.out.println("Enter name.");

n=s.next();

         s1=new SYMarks();

t1=new TYMarks();

s1.accept();

t1.accept();

}


public void display()

{

System.out.println("Roll No :"+r);

System.out.println("Name:"+n);

s1.display();

t1.display();

}

public void grade()

{

int total=s1.total()+t1.total();

double per=total/5;

System.out.println("Per :"+per);

if(per>=70)

System.out.println("A Grade");

else if(per<70 && per>=60)

System.out.println("B Grade");

else if(per<60&&per>=50)

System.out.println("C Grade");

else if(per<50 && per>=40)

System.out.println("Pass Class");

else

System.out.println("Fail");

}

}


class student

{

public static void main(String args[])

{

Scanner s=new Scanner(System.in);

System.out.println("Enter how many objects.");

int n=s.nextInt();

student1 st[]=new student1[n];

for(int i=0;i<n;i++)

{

st[i]=new student1();

st[i].accept();

                        System.out.println(st[i].r);

}

for(int i=0;i<n;i++)

{

st[i].display();

st[i].grade();

}

}

}




Post a Comment

0 Comments