PERSONAL DETAILS USING CLASS


AIM
            To write a Java program to get the information from the student and display it.

ALGORITHM
STEP 1: Start the program
STEP 2: Define the details of a class.
STEP 3: Declare the variable name, reg no, address, gender, age, course, department, hostel-fee,
               Semester-fee, total-fees.
STEP 4: Define a member function read() in that function read the input from the user.
STEP 5: Define a member function display() in that function display the details about the           
              Students.
STEP 6: Define a student class.
STEP 7: In that define the main function and declare the object for detail class.
STEP 8: Declare an object of the detail class.
STEP 9: Call the member function get detail and display the detail.
STEP 10: Stop the program.
 
PROGRAM
import java.io.*;
class ex1
{
public static void main(String args[])throws IOException
{
Details studdetail=new Details();
studdetail.getdetails();
studdetail.printdetails();
}
}
class Details
{
String name;
String regno;
String get;
int age;
int semfee;
int hostelfee;
String address;
String gender;
String department;
String branch;
void getdetails()throws IOException
{
BufferedReader d= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the regno:");
regno=d.readLine();
System.out.println("Enter the name:");
name=d.readLine();
System.out.println("Enter the age:");
age=Integer.parseInt(d.readLine());
System.out.println("Enter the Semester fees");
semfee=Integer.parseInt(d.readLine());
System.out.println("Enter the hostel fees");
hostelfee=Integer.parseInt(d.readLine());
System.out.println("Enter the gender");
gender=d.readLine();
System.out.println("Enter the address:");
address=d.readLine();
System.out.println("Enter the branch");
branch=d.readLine();
System.out.println("Enter the department");
department=d.readLine();
}
void printdetails() throws IOException
{
System.out.println("\t\t student details");
System.out.println("\t name:"+name);
System.out.println("\t registerno:"+regno);
System.out.println("\t Age:"+age);
System.out.println("\t gender:"+gender);
System.out.println("\t branch:"+branch);
System.out.println("\t department:"+department);
System.out.println("\t semester fees:"+semfee);
System.out.println("\t hostel fees:"+hostelfee);
System.out.println("\t total fees:"+(semfee+hostelfee));
}
}
















OUTPUT
Enter the regno:08ca023
Enter the name:jennifer
Enter the age:21
Enter the Semester fees:30000
Enter the hostel fees:12000
Enter the gender:female
Enter the address:coonoor
Enter the branch:computer application
Enter the department:mca
      
 student details
 name:jennifer
 registerno:08ca023
 Age:21
 gender:female
 branch:computer application
 department:mca
 semester fees:30000
 hostel fees:12000
 total fees:42000

0 comments: