Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Monday, September 3, 2012

CJ-24 : Enter student details using 2 functions

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
***********************************************************************************************
Refer Program to enter Student Details also.
***********************************************************************************************

import java.io.*;
class student1
{
    int rno;
    String name, branch;  
    void get()
    {
     
        try {
            DataInputStream x = new DataInputStream(System.in);
            System.out.println("Enter Roll Number");
            rno = Integer.parseInt(x.readLine());
            System.out.println("Enter Name");
            name = x.readLine();
            System.out.println("Enter Branch");
            branch = x.readLine();
        } catch (Exception e) {
           
        }
    }

    void display() {
        System.out.println(" ");
        System.out.println("=========================");
        System.out.println("STUDENT DETAILS :");
        System.out.println("-----------------");
        System.out.println("Roll Number =" + rno);
        System.out.println("Name =" + name);
        System.out.println("Branch =" + branch);
    }
}


    class exam
    {

        int regno, mark;

        void read() {
            try {
                DataInputStream x = new DataInputStream(System.in);
                System.out.println("Enter Register Number");
                regno = Integer.parseInt(x.readLine());
                System.out.println("Enter mark");
                mark = Integer.parseInt(x.readLine());
            } catch (Exception e) {
               
            }
        }

        void write() {
            System.out.println("=========================");
            System.out.println("EXAM DETAILS :");
            System.out.println("--------------");
            System.out.println("Register Number =" + regno);
            System.out.println("Mark =" + mark);
        }
    }
 

        class main1
        {

            public static void main(String args[]) {
                student1 s = new student1();
                exam e = new exam();
                s.get();
                e.read();
                s.display();
                e.write();

            }
     
    }

=========================================================================
Output : 


Enter Roll Number
1
Enter Name
Priyada
Enter Branch
Computer Science
Enter Register Number
746092
Enter mark
500
 =========================
STUDENT DETAILS :
-----------------
Roll Number =1
Name =Priyada
Branch =Computer Science
=========================
EXAM DETAILS :
--------------
Register Number =746092
Mark =500