Define class student(rno,name,marks1,marks2) .Define result class(total,percentage) inside the student class.accept the student details and display the Marksheet with Rno,name,marks1,Marks2,total,percentage.(use inner class concept.)||EasyCoding45

 In this tutorial, we are going to learn how we can Define a class student(rno,name,marks1,marks2) and Define result class(total,percentage) inside the student class. and by accepting the student details and also displaying the Marksheet with Rno,name,marks1,Marks2,total,percentage.(by using inner class concept.)


Program ::--


import java.util.*;

class student

{

int rno;

String name;

int marks1,marks2;

Scanner sc=new Scanner(System.in);

class result

{

int total;

double per;

void accept()

{

System.out.println("Enter Student Roll no:");

rno=sc.nextInt();

System.out.println("Enter Student Name:");

name=sc.next();

System.out.println("Enter Marks1:");

marks1=sc.nextInt();

System.out.println("Enter Marks2:");

marks2=sc.nextInt();

}

void display()

{

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

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

System.out.println("Student Marks1:"+marks1);

System.out.println("Student Marks2:"+marks2);

total=marks1+marks2;

System.out.println("Total marks:"+total);

per=total/2.0;

System.out.println("Total percentage:"+per);

}

}

public static void main(String a[])

{

student s=new student();

student.result sr=s.new result();

sr.accept();

sr.display();

}

}


Output ::--



                                

                                                            Thank You💚

Comments