English

Given below is a program. Identify the following: class Student { String Name;int Age ; double Marks; void fnInput () { Scanner sc = new Scanner(System.in); System.out.println("Enter Name:");

Advertisements
Advertisements

Question

Given below is a program. Identify the following:

class Student
{
    String Name;int Age ; double Marks;
    void fnInput ()
    {
       Scanner sc = new Scanner(System.in);
       System.out.println("Enter Name:");
       Name = sc.nextLine ();
       System.out.println("Enter Age:");
       Age = sc.nextInt ();
       System.out.println("Enter Marks:");
       Marks = sc.nextDouble ();
    }
    void fnDisplay()
    {
       System.out.println("Name is:"+Name);
       System.out.println("Age is:"+Age);
       System.out.println("Marks is:"+Marks );
       if (Marks >=80)
       System.out.println(“Grade is A");
       else if (Marks >=60)
          System.out.println("Grade is B");
       else if (Marks >=40)
          System.out.println("Grade is C");
       else
          System.out.println(“Grade is F");
    }
    void main()
    {
       Student obSt1 = new Student ();
       obSt1.fnInput ();
       obSt1.fnDisplay ();
       Student obSt2 = new Student ();
       obSt2.fnInput ();
       obSt2.fnDisplay ();
    }
}
Code Writing
Advertisements

Solution

Class name : Student
Object name : obSt1, obSt2
member data : Name; Age; Marks;
member methods : fnInput(); fnDisplay(); main()
shaalaa.com
  Is there an error in this question or solution?
Chapter 2: Class as the Basis of all Computation - Exercises [Page 66]

APPEARS IN

Rupa Pandit Computer Applications [English] Class 10 ICSE
Chapter 2 Class as the Basis of all Computation
Exercises | Q 6. | Page 66
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×