0% found this document useful (0 votes)
53 views15 pages

Compapro 10

The document outlines a computer application assignment for class 10 students which involves completing 5 Java programs from a list of 10 programs of varying difficulty levels. The programs cover concepts like Fibonacci series, Floyd's triangle, diamond pattern of stars, basic calculator operations, array programs to find sum of even and odd numbers separately, class definition to calculate student marks and more.

Uploaded by

seravanakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views15 pages

Compapro 10

The document outlines a computer application assignment for class 10 students which involves completing 5 Java programs from a list of 10 programs of varying difficulty levels. The programs cover concepts like Fibonacci series, Floyd's triangle, diamond pattern of stars, basic calculator operations, array programs to find sum of even and odd numbers separately, class definition to calculate student marks and more.

Uploaded by

seravanakumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Tender Heart School

Class - X (2021-22)

Computer Application Assignment

Students of Class X-Computer Application as per requirement of CISCE (ICSE


Board), have to make a practical file in the subject of Computer Application

Work Specification: Java assignments to be completed for ICSE 2021-22


practical file

Materials /Resources Required: Computer with BlueJ installed, A4 Sheets ruled and
plain sheets for output.

Instructions /Guidelines : Complete any 5 Assignments from the assignment


list.

1. For each assignment, arrange sheets having:


a. Problem Statement
b. Coding
c. Input / Output screen
2. Each Page must have a specified page number.
3. New program will start from new page.
4. Presentation must be upto the mark and impressive as assignment is an essential part of
internal assessment by ICSE board.
5. For reference a sample programs are being attached with.

List of Programs covering various levels of difficulties as per syllabus given by


CISCE (ICSE Board)

1. Write a program in Java to accept a number and Display Fibonacci series up to a


given number.
2. To print the Floyd’s triangle.
3. To display diamond of stars(*) based on value of n.
4. Program to make a simple calculator.
5. Write a program 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.
6. Write a program to create an object and invoke student name , marks obtained in
subjects, total of marks, average of marks.
7. Define a class Bill that calculates the telephone bill of a consumer having name ,
number of calls, total bill.
8. Write a program to check whether the number is prime or not prime.
9. Program to display Sandglass Star Pattern.
10. 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.

1
1. Write a program in Java to accept a number and Display Fibonacci series up
to a given number

Fibonacci Series: The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5,


8, 13, 21, 34, … The first two numbers in the series is ‘0’ and ‘1’ and every next
number is found by adding up the two numbers before it. The 2 is found by adding
the two numbers before it (1+1) Similarly, the 3 is found by adding the two numbers
before it (1+2), And the 5 is (2+3), and so on!

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) {

int n = 100, firstTerm = 0, secondTerm = 1;

System.out.println("Fibonacci Series Upto " + n + ": ");

while (firstTerm<= n) {
System.out.print(firstTerm + ", ");

intnextTerm = firstTerm + secondTerm;


firstTerm = secondTerm;
secondTerm = nextTerm;

}
}
}

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 {

// Main driver method


public static void main(String[] args)
{
// No of rows to be printed
int n = 5;

// Creating and initializing variable for


// rows, columns and display value
int i, j, k = 1;

// Nested iterating for 2D matrix


// Outer loop for rows
for (i = 1; i <= n; i++)
{

// Inner loop for columns


for (j = 1; j <= i; j++) {

// Printing value to be displayed


System.out.print(k + " ");

// Incremeting value displayed


k++;
}

// Print elements of next row


System.out.println();
}
}
}

3
3. To display diamond of stars(*) based on value of n. For example if n=7 then
print,

importjava.util.Scanner;

public class MainClass


{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);

//Taking noOfRows value from the user

System.out.println("How Many Rows You Want In Your Diamond?");

intnoOfRows = sc.nextInt();

//Getting midRow of the diamond

intmidRow = (noOfRows)/2;

//Initializing row with 1

int row = 1;

System.out.println("Here Is Your Diamond : ");

//Printing upper half of the diamond

for (int i = midRow; i > 0; i--)


{
//Printing i spaces at the beginning of each row

for (int j = 1; j <= i; j++)


{
System.out.print(" ");
}

//Printing j *'s at the end of each row

for (int j = 1; j <= row; j++)


{
System.out.print("* ");
}

System.out.println();

//Incrementing the row

row++;
}

4
//Printing lower half of the diamond

for (int i = 0; i <= midRow; i++)


{
//Printing i spaces at the beginning of each row

for (int j = 1; j <= i; j++)


{
System.out.print(" ");
}

//Printing j *'s at the end of each row

for (int j = row; j > 0; j--)


{
System.out.print("* ");
}

System.out.println();

//Decrementing the row

row--;
}
}
}

Output :

How Many Rows You Want In Your Diamond?


7
Here Is Your Diamond :
*
**
***
****
***
**
*

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:");

/* We are using data type double so that user


* can enter integer as well as floating point
* value
*/
num1 = scanner.nextDouble();
System.out.print("Enter second number:");
num2 = scanner.nextDouble();

System.out.print("Enter an operator (+, -, *, /): ");


char operator = scanner.next().charAt(0);

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;

/* If user enters any other operator or char apart from


* +, -, * and /, then display an error message to user
*
*/
default:
System.out.printf("You have entered wrong operator");
return;
}

System.out.println(num1+" "+operator+" "+num2+": "+output);


}} Output:
Enter first number:40
Enter second number:4
Enter an operator (+, -, *, /): /
40.0 / 4.0: 10.0

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;

public class KboatSDAOddEvenSum


{
public static void main(String args[]) {

Scanner in = new Scanner(System.in);


intarr[] = new int[20];

System.out.println("Enter 20 numbers");
for (int i = 0; i <arr.length; i++) {
arr[i] = in.nextInt();
}

intoddSum = 0, evenSum = 0;

for (int i = 0; i <arr.length; i++) {


if (arr[i] % 2 == 0)
evenSum += arr[i];
else
oddSum += arr[i];
}

System.out.println("Sum of Odd numbers = " + oddSum);


System.out.println("Sum of Even numbers = " + evenSum);
}
}

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

Member Methods Purpose


void accept() To input marks in English, Hindi and Maths
void compute() To calculate total marks and average of 3 subjects
void display() To show all the details viz. name, marks, total and
average
Write a program to create an object and invoke the above methods.
importjava.util.Scanner;
public class Student
{
private String name;
privateinteng;
privateinthn;
privateintmts;
private double total;
private double avg;
public void accept() {
Scanner in = new Scanner(System.in);
System.out.print("Enter student name: ");
name = in.nextLine();
System.out.print("Enter marks in English: ");
eng = in.nextInt();
System.out.print("Enter marks in Hindi: ");
hn = in.nextInt();
System.out.print("Enter marks in Maths: ");
mts = in.nextInt();
}
public void compute() {
total = eng + hn + mts;
avg = total / 3.0;
}
public void display() {
System.out.println("Name: " + name);
System.out.println("Marks in English: " + eng);
System.out.println("Marks in Hindi: " + hn);
System.out.println("Marks in Maths: " + mts);
System.out.println("Total Marks: " + total);
System.out.println("Average Marks: " + avg);
}

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

Member Methods Purpose


Bill() constructor to initialize data members with default
initial value
Bill() parameterised constructor to accept billno, name
and no. of calls consumed
Calculate() to calculate the monthly telephone bill for a
consumer as per the table
Display() to display the details

Units consumed Rate


First 100 calls 0.60 / call
Next 100 calls 0.80 / call
Next 100 calls 1.20 / call
Above 300 calls 1.50 / call
Fixed monthly rental applicable to all consumers: 125
Create an object in the main() method and invoke the above functions to perform the
desired task.
importjava.util.Scanner;

public class Bill


{
privateintbno;
private String name;
privateint call;
private double amt;

public Bill() {
bno = 0;
name = "";
call = 0;
amt = 0.0;
}

public Bill(intbno, String name, int call) {


this.bno = bno;
this.name = name;
this.call = call;
}
public void calculate() {
double charge;
if (call <= 100)
charge = call * 0.6;

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);

amt = charge + 125;


}

public void display() {


System.out.println("Bill No: " + bno);
System.out.println("Name: " + name);
System.out.println("Calls: " + call);
System.out.println("Amount Payable: " + amt);
}
public static void main(String args[]) {

Scanner in = new Scanner(System.in);


System.out.print("Enter Name: ");
String custName = in.nextLine();
System.out.print("Enter Bill Number: ");
intbillNum = in.nextInt();
System.out.print("Enter Calls: ");
intnumCalls = in.nextInt();

Bill obj = new Bill(billNum, custName, numCalls);


obj.calculate();
obj.display();
}
}

Output

11
8. Write a program by using a class with the following specifications:
Class name — Prime
Data members — private int n
Member functions:

1. void input() — to input a number


2. void checkprime() — to check and display whether the number is prime or not

Use a main function to create an object and call member methods of the class.
importjava.util.Scanner;

public class Prime


{
privateint n;

public void input() {


Scanner in = new Scanner(System.in);
System.out.print("Enter the number: ");
n = in.nextInt();
}

public void checkprime() {


booleanisPrime = true;
if (n == 0 || n == 1)
isPrime = false;
else { Output

for (int i = 2; i <= n / 2; i++) {


if (n % i == 0) {
isPrime = false;
break;
}
}
}

if (isPrime)
System.out.println("Prime Number");
else
System.out.println("Not a Prime Number");
}

public static void main(String args[])


{

Prime obj = new Prime();


obj.input();
obj.checkprime();
}
}

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.

public class CommonCharacter {

public void removeCommonCharacter(String s1, String s2){


System.out.println("Before removing common character s1 " + s1);
System.out.println("Before removing common character s2 " + s2);
String commonChars = "";

for (int i = 0; i < s1.length(); i++) {


for (int j = 0; j < s2.length(); j++) {
if (s1.charAt(i) == s2.charAt(j)) {
commonChars += s1.charAt(i);
}
}
}

for(int i = 0; i <commonChars.length(); i ++) {


String charToRemove = commonChars.charAt(i)+"";
s1 = s1.replace(charToRemove, "");
s2 = s2.replace(charToRemove, "");
}
System.out.println("After removing common character " + s1);
System.out.println("After removing common character " + s2);
}

public static void main(String[] args){


CommonCharacter common Character = new Common Character();
common Character.removeCommon Character("abcfgh", "aasdf");
}
}

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: ");

int rows = sc.nextInt();


for (int i= 0; i<= rows-1 ; i++)
{
for (int j=0; j <i; j++)
{
System.out.print(" ");
}
for (int k=i; k<=rows-1; k++) { System.out.print("*" + " "); } System.out.println(""); }
for (int i= rows-1; i>= 0; i--)
{
for (int j=0; j< i ;j++)
{
System.out.print(" ");
}
for (int k=i; k<=rows-1; k++)
{
System.out.print("*" + " ");
}
System.out.println("");
}
sc.close();
}
}

Output
Enter the number of rows: 5

*****
****
***
**
*
*
**
***
****
*****

14
Tender Heart School

Class - X (2021-22)

Computer Application- Project

Students of Class X-Computer Application as per requirement of CISCE (ICSE


Board), have to make one real life project using the concepts taught.

Work Specification: Java Project to be completed for ICSE 2021-22

Materials /Resources Required: Computer with BlueJ installed, A4 Sheets for


Printing.

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy