Define a class Candidate with the following description
- Members are : RNo of int type, Name of type String, Score of type float, Remarks of type String.
- Member functions : AssignRem() to assign Remarks as per the Score obtained by a candidate. Score range are given below:
| Score | Remarks |
| >=50 | Selected |
| <50 | Not Selected |
- A function ENTER() to allow user to enter values for RNo, Name, Score and call function AssignRem() to assign the remarks.
- A function DISPLAY() to allow user to view the content of all the data members.
import java.util.*;
class CANDIDATE
{
int RNo;
String Name;
int Score;
String Remarks;
public void AssignRem(){
if(Score>=50)
Remarks = "Selected";
else
Remarks="Not selected";
}
public void Enter(){
Scanner sc = new Scanner(System.in);
System.out.println("Enter Roll Number : ");
RNo=sc.nextInt();
System.out.println("Enter Name : ");
Name=sc.next();
System.out.println("Enter Score : ");
Score=sc.nextInt();
AssignRem();
}
public void Display(){
System.out.println("Result ");
System.out.println("RNo : "+RNo);
System.out.println("Name : "+Name);
System.out.println("Score : "+Score);
System.out.println("Remarks : "+Remarks);
}
}
class Score
{
public static void main(String args[])
{
CANDIDATE cand=new CANDIDATE();
cand.Enter();
cand.Display();
}
}
Save the above Program with “Score.Java” then compile it with the following command :
javac Score.java //to compile the code java Score // to run the code
Output is :
Enter Roll Number : 12 Enter Name : Amit Enter Score : 70 Result RNo : 12 Name : Amit Score : 70 Remarks : Selected