Define a class Candidate with the following descriptions Private members:A data member Rno(Registration number), A data member Name of type String, A data member Score of type String, A data member Remarks of type String, A member function AssignRem() to assign the remarks as per the score obtained by a candidate. Score range and the respective remarks are shown as follows: Score Remarks >= 50 Selected , < 50 Not selected. Public members: A function ENTER() to allow the user to enter values for Rno, Name, Score and call function AssignRem() to assign grade. A function DISPLAY() to allow user to view the content of all data members. Also, create a main() method to create an object and show its implementation by calling the above methods.

 THE FOLLOWING PROGRAM SEGMENT SHOWS HOW TO CREATE A CLASS Candidate() AND PERFORM THE OPERATIONS TO PRINT THE REMARK.

import java.util.*;

class Candidate

{

    private long Rno;

    private String Name;

    private float Score;

    private String Remarks;

    private void AssignRem()

    {

        if(Score >= 50)

        {

            Remarks = "Selected";

        }

        else

        {

            Remarks = "Not selected";

        }

    }

    public void ENTER()

    {

        Scanner ob = new Scanner (System.in);

        System.out.println("Enter the Registration Number");

        Rno = ob.nextLong();

        System.out.println("Enter the Name");

        Name = ob.nextLine();

        

        System.out.println("Enter the Score");

        Score = ob.nextFloat();

        AssignRem();

    }

    void DISPLAY()

    {

        System.out.println("Registration number = " +Rno);

        System.out.println("Name is = "+Name);

        System.out.println("Score is = "+Score);

        System.out.println("Remarks = "+Remarks);

    }

    public static void main (String args[])

    {

        Candidate obj = new Candidate();

        obj.ENTER();

        obj.DISPLAY();

    }

}

The above program is compiled and is without any error.

Hope you guys found it helpful.

Please share it with your friends and comment down in the comment section below.

Follow https://askrisfor.blogspot.com/ for more such updates.

Visit us again.

Thank you!!

Comments

Popular Posts