Compapro 10
Compapro 10
Class - X (2021-22)
Materials /Resources Required: Computer with BlueJ installed, A4 Sheets ruled and
plain sheets for output.
1
1. Write a program in Java to accept a number and Display Fibonacci series up
to a given number
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181,
6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, …
class Fibonacci {
public static void main(String[] args) {
while (firstTerm<= n) {
System.out.print(firstTerm + ", ");
}
}
}
2
2. To print the Floyd’s triangle [Given below]
1
23
456
7 8 9 10
11 12 13 14 15
/ Java program to display Floyd's triangle
// Importing Java libraries
importjava.util.*;
class GFG {
3
3. To display diamond of stars(*) based on value of n. For example if n=7 then
print,
importjava.util.Scanner;
intnoOfRows = sc.nextInt();
intmidRow = (noOfRows)/2;
int row = 1;
System.out.println();
row++;
}
4
//Printing lower half of the diamond
System.out.println();
row--;
}
}
}
Output :
5
4. Program to make a calculator using switch case in Java
importjava.util.Scanner;
public class JavaExample {
public static void main(String[] args) {
double num1, num2;
Scanner scanner = new Scanner(System.in);
System.out.print("Enter first number:");
scanner.close();
double output;
switch(operator)
{
case '+':
output = num1 + num2;
break;
case '-':
output = num1 - num2;
break;
case '*':
output = num1 * num2;
break;
case '/':
output = num1 / num2;
break;
6
5. Write a program in Java to store 20 numbers (even and odd numbers) in a
Single Dimensional Array (SDA). Calculate and display the sum of all even
numbers and all odd numbers separately.
importjava.util.Scanner;
System.out.println("Enter 20 numbers");
for (int i = 0; i <arr.length; i++) {
arr[i] = in.nextInt();
}
intoddSum = 0, evenSum = 0;
Output
7
6. Define a class Student with the following specifications
Data Members Purpose
String name To store the name of the student
inteng To store marks in English
inthn To store marks in Hindi
intmts To store marks in Maths
double total To store total marks
doubleavg To store average marks
8
public static void main(String args[]) {
Student obj = new Student();
obj.accept();
obj.compute();
obj.display();
}
}
Output
9
7. Define a class Bill that calculates the telephone bill of a consumer with the
following description:
Data Members Purpose
intbno bill number
String name name of consumer
int call no. of calls consumed in a month
doubleamt bill amount to be paid by the person
public Bill() {
bno = 0;
name = "";
call = 0;
amt = 0.0;
}
10
else if (call <= 200)
charge = 60 + ((call - 100) * 0.8);
else if (call <= 300)
charge = 60 + 80 + ((call - 200) * 1.2);
else
charge = 60 + 80 + 120 + ((call - 300) * 1.5);
Output
11
8. Write a program by using a class with the following specifications:
Class name — Prime
Data members — private int n
Member functions:
Use a main function to create an object and call member methods of the class.
importjava.util.Scanner;
if (isPrime)
System.out.println("Prime Number");
else
System.out.println("Not a Prime Number");
}
12
9. Write a program to input two strings. Check both the strings and remove all
common characters from both the strings. Print both the strings after
removing the common characters.
13
10.Write a program to print Sandglass Star Pattern
importjava.util.Scanner;
public class Edureka
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of rows: ");
Output
Enter the number of rows: 5
*****
****
***
**
*
*
**
***
****
*****
14
Tender Heart School
Class - X (2021-22)
Instructions / Guidelines :
1. First step is to design a problem then, invention of an algorithm and only then
implementation and testing.
2. First page will be the cover page. Write your name, class, section, subject, and to
whom it is to be submitted.
3. Acknowledgement
4. Index
5. Topic of the project
6. Content
7. Conclusion
8. Bibliography / References
9. Each Page must have a specified page number.
10.Presentation must be upto the mark and impressive as project is an essential part
of internal assessment by ICSE board.
11.Before spiral binding take the printout and get them checked from subject
teacher.
12. Softcopy also required in form of CD- having name, class, section, roll number
and subject
Suggested list of Projects as per CISCE (ICSE Board) is given below. Complete any
1 Project.
1. Find the Country capital and telephone dialing code, based on the Country
name
2. Making some sort of Calculator
3. Banking: Search for a customer, display details, allow transaction
4. School library system
5. Make a game- Example: Crorepati Quiz Game, Bouncing Ball
6. Traffic lights, traffic signal management and control system
7. Inventory management in Retail Outlet
8. Office attendance
9. Company Payroll
10.Automatic Teller Machines (ATM )
11.A musical composition
12.A clinical diagnostic system
13.Cricket Score Board
14.Graphical Analog CLOCK
15.Theatre Tickets Sales
16.Train Reservation
15