Sunday, 16 September 2012

Java program codes: Read Student details in an interactive manner usin...

Read Student details in an interactive manner using java programming


import java.io.*;
class ReadKeyboard
{
 public static void main(String args[])
        throws IOException
            {
char c;
                  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                                               DataInputStream in=new DataInputStream(System.in);
String name;
int number,total=0;
int marks[]=new int[5];
try
{
System.out.println("Enter Student Name:");
name=br.readLine();
System.out.println("Enter Number :");
number=Integer.parseInt(in.readLine());
for(int j=0;j<5;j++)
{
System.out.println("Enter Subject" + (j+1)+" Marks");
marks[j]=Integer.parseInt(in.readLine());
total=total+marks[j];
}

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

System.out.println("student Total marks: "+total);
System.out.println("Student Average: "+ (float)(total/5) );
}
catch(Exception e) { }
}



}


No comments:

Post a Comment