Write a java program Create a student class with student_id, subject_code and marks which takes input using method getdata() and display result using putdata() method. - Pratik Ghelani

Pratik Ghelani

Breaking

Friday, January 25, 2019

Write a java program Create a student class with student_id, subject_code and marks which takes input using method getdata() and display result using putdata() method.


Program:-

import java.util.Scanner;
public class student {
long student_id;
int subject_code,marks;
Scanner s=new Scanner(System.in);
void getdata()
{
System.out.println("Enter the student_id :");
student_id=s.nextLong();
System.out.println("Enter the subject_code:");
subject_code=s.nextInt();
System.out.println("Enter the marks:");
marks=s.nextInt();
}
void putdata()
{
System.out.println(" student_id :"+ student_id);
System.out.println("subject_code:"+subject_code);
System.out.println("marks:"+marks);
}
public static void main(String[] args) {
student s1=new student();
s1.getdata();
s1.putdata();
}
}

Output:-



No comments:

Post a Comment