Page 274 - ComputerScience_Class_11
P. 274
24 System.out.print(" , " + c);
25 a=b;
26 b=c;
27 }
28 }
29 }
30 public static void main(String[] args)
31 {
32 Scanner sc= new Scanner(System.in);
33 int n;
34 System.out.println("Enter the last term of the Fibonacci series : ");
35 n= sc.nextInt();
36 fibo ob = new fibo();
37 ob.accept(n);
38 ob.print();
39 }
40 }
The output of the preceding program is as follows:
BlueJ: Terminal Window - Java
Options
Enter the last term of the Fibonacci series :
5
0 , 1 , 1 , 2 , 3
Program 4 Define a class student_marks as described below:
Data Members/Instance variables:
name, age, marks1, marks2 (marks in 2 subjects), max_marks, ave_marks
Member Methods
i. To accept the details of a student
ii. To compute the average and the maximum out of two marks
iii. To display the name, age and marks in two subjects, maximum and average marks
Write a main method to create an object of a class and call the above member methods.
1 import java.util.*;
2 class student_marks
3 {
4 String name;
5 int age, marks1, marks2, max_marks;
272 Touchpad Computer Science (Ver. 3.0)-XI

