Page 272 - CA_Blue( J )_Class10
P. 272
20 {
21 System.out.println("Surface Area of the Sphere:" +surface_area);
22 System.out.println("Volume of a Sphere:" + volume);
23 }
24 public static void main()
25 {
26 shape_sphere ob = new shape_sphere();
27 ob.accept();
28 ob.cal_surfacearea();
29 ob.cal_volume();
30 ob.display();
31 }
32 }
Define a class student described as below:
Program 2 Data members/instance variables
name, age, m1, m2, m3, max, avg
Member methods
i. To accept the details of a student.
ii. To compute the average and the maximum out of three marks.
iii. To display the name, age, marks in two subjects, maximum and average.
Write a main method to create an object of a class and call the above member methods.
1 import java.util.*;
2 class Student1
3 {
4 String name;
5 int age,m1,m2,m3,max;
6 float avg;
7 void input()
8 {
9 Scanner sc=new Scanner(System.in);
10 System.out.println("Enter your name:");
11 name=sc.next();
12 System.out.println("Enter marks in 3 subjects:");
13 m1=sc.nextInt();
14 m2=sc.nextInt();
15 m3=sc.nextInt();
270270 Touchpad Computer Applications-X

