student

4
PROGRAM import java.io.*; import java.lang.*; class Student { String name; int rno; int sub1,sub2; int tot; float avg; void get()throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.println("Enter name of student:"); name=br.readLine(); System.out.println("Enter roll no:"); rno=Integer.parseInt(br.readLine()); System.out.println("Enter mark of sub1:"); sub1=Integer.parseInt(br.readLine()); System.out.println("Enter mark of sub2:"); sub2=Integer.parseInt(br.readLine()); } void display() { tot=sub1+sub2;

Upload: sreejith-ps

Post on 01-Feb-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Student

PROGRAM

import java.io.*;

import java.lang.*;

class Student

{

String name;

int rno;

int sub1,sub2;

int tot;

float avg;

void get()throws IOException

{

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("Enter name of student:");

name=br.readLine();

System.out.println("Enter roll no:");

rno=Integer.parseInt(br.readLine());

System.out.println("Enter mark of sub1:");

sub1=Integer.parseInt(br.readLine());

System.out.println("Enter mark of sub2:");

sub2=Integer.parseInt(br.readLine());

}

void display()

{

tot=sub1+sub2;

avg=(tot*100)/200;

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

System.out.println("Roll no:"+rno);

System.out.println("Total:"+tot);

Page 2: Student

System.out.println("Percentage:"+avg);

if(avg>=90)

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

else if(avg>=80)

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

else if(avg>=70)

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

else if(avg>=60)

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

else

System.out.println("Failed");

}

}

class Student1

{

public static void main(String args[]) throws IOException

Student s=new Student();

s.get();

s.display();

}

Page 3: Student

OUTPUT

proglab34@proglab34:~/sr$ javac Student1.java

proglab34@proglab34:~/sr$ java Student1

Enter name of Student:

Arun

Enter roll no:

34

Enter mark of sub1:

80

Enter mark of sub2:

56

Name :Arun

Roll no : 34

Total :155

Percentage :77.0

Grade C