trying to write a program by implementing single inheritance... need help please
<p>I want to get the values that i got from the mark class and evaluate in the result class. How can I do that?</p>

<pre><code>import java.util.*;
import java.lang.*;
import java.io.*;

class Marks{

            float age,S1,S2,S3,S4,S5;
            String Name,Roll;



            void displayMarks() {



                Scanner input = new Scanner(System.in);

                System.out.println("Enter your name:");
                Name=input.nextLine();

                System.out.println("Enter your Roll no:");
                Roll=input.nextLine();

                System.out.println("Enter the marks of first subject:");
                S1=input.nextFloat();

                System.out.println("Enter the marks of second subject:");
                S2=input.nextFloat();

                System.out.println("Enter the marks of third subject:");
                S3=input.nextFloat();

                System.out.println("Enter the marks of fourth subject:");
                S4=input.nextFloat();

                System.out.println("Enter the marks of fifth subject:");
                S5=input.nextFloat();

            }
}

class Result extends Marks{

void displayResults(){


        float total,average;
        total=(S1+S2+S3+S4+S5);
        average=(total/5);

        System.out.println("Roll no:"+Roll);
        System.out.println("Name:"+Name);
        System.out.println("Age:"+age);
        System.out.println("The marks of the individual subjects are:subject1="+S1+ " ,subject2="+S2+ " ,subject3="+S3+ " ,subject4="+S4+ " ,subject5="+S5);
        System.out.println("Total:"+total);
        System.out.println("Average:"+average);
    }
}

public class Lab04{
    public static void main(String [] args){

            Marks m=new Marks();
            Result r=new Result();
            m.displayMarks();
            r.displayResults();
    }
}
</code></pre>
