Student Details Program in Java
Program Name:- student1.java
import java.io.*;
class studentdetail
{
int sno;
String sname,major,yos;
void getdata()throws IOException
{
DataInputStream in=new DataInputStream(System.in);
System.out.print("\n Enter the student number\t:");
sno=Integer.parseInt(in.readLine());
System.out.print("\n Enter the student name\t:");
sname=in.readLine();
System.out.print("\n Enter the student Major\t:");
major=in.readLine();
System.out.print("\n Enter the year of student\t:");
yos=in.readLine();
}
}
class markdetails extends studentdetail
{
int m1,m2,m3,m4,tot;
String res;
void read()throws IOException
{
DataInputStream in=new DataInputStream(System.in);
getdata();
System.out.print("\n Enter the mark1\t:");
m1=Integer.parseInt(in.readLine());
System.out.print("\n Enter the mark2\t:");
m2=Integer.parseInt(in.readLine());
System.out.print("\n Enter the mark3\t:");
m3=Integer.parseInt(in.readLine());
System.out.print("\n Enter the mark4\t:");
m4=Integer.parseInt(in.readLine());
}
void total()
{
tot=m1+m2+m3+m4;
}
void result()
{
if((m1>=50)&&(m2>=50)&&(m3>=50)&&(m4>=50))
res="Pass";
else
res="Fail";
}
void display()
{
System.out.println("\n\n \t Student details \n\n");
System.out.println("\n Student number\t:"+sno);
System.out.println("\n Student name\t:"+sname);
System.out.println("\n Student major\t:"+major);
System.out.println("\n Year of Study\t:"+yos);
System.out.print("\n mark1: \t"+m1+"\n\n mark2: \t"+m2+"\n\n mark3: \t"+m3+"\n\n mark4: \t"+m4);
System.out.print("\n\n Total: \t"+tot+"\n\n Result: "+res);
}
}
class student1
{
public static void main(String[]args)throws IOException
{
markdetails in=new markdetails();
in.read();
in.total();
in.result();
in.display();
}
}
No comments:
Post a Comment