Computer Assignment
Computer Assignment
mpu
ter
Assi
gnm Name: Priyam Saha
ent CLASS: X
SEC:B
ROLL NO.:14
SESSION:2022-23
SUBJECT:Computer Project File
ACKNOWLEDGEMENT
I would like to express my special thanks of gratitude
to my teacher Mrs. Preeti Sarkar, who gave me
the golden opportunity to do this wonderful project of
Computer Assignment File.
Priyam Saha
X-B
Teacher’s Signature
Contents
Sl.No. Assignment Topic Pg. No.
1 Introduction 1
23 Bibliography 55
24 Declaration 56
25 Photo gallery 57
INTRODUCTION
Every School needs to maintain data bases of the student.
The data base on the students is required for general
purpose like collection fees using this software, under the
Office module, the database on the students can be created,
modified. The same can be used to verify whether any
student is due for payment of term fees etc.
Pg-01
Assignm
ent No.: TOPIC: - Conversion of temperature from
Celsius to Fahrenheit
01 And vice versa.
Pg-02
Q1: Write a program in java accept temperature in celcius
and covert it to Fahrenheit and vise-versa
Solution:-
import java.util.*;
class c2f_f2c_menu_driven {
public static void main (String [] args)
{
float t;
int ch;
Scanner ki=new Scanner (System.in);
do {
System.out.print("\n 1. Centigrade to Fahrenheit");
System.out.print("\n 2. Fahrenheit to Centigrade");
System.out.print("\n 0. Exit");
System.out.print("\nEnter temperature ");
t=ki. next Float ();
System.out.print("\nEnter your choice ");
ch=ki.nextInt();
switch(ch){
case 1:
System.out.print("\nIn Farenhiet "+c2f(t));
break;
case 2:
System.out.print("\nIn Centigrade "+f2c(t));
break;
case 0:
System.exit(0);
break;
default:
System.out.print("Wrong choice ????"+ch+" Invalid option ");
break;
}//end switch
}while(ch!=0);
return;
}//end main
In Fahrenheit 104.0
1. Centigrade to Fahrenheit
2. Fahrenheit to Centigrade
0. Exit
Enter temperature 56
In Centigrade 13.333333
1. Centigrade to Fahrenheit
2. Fahrenheit to Centigrade
0. Exit
VARIABLE DESCRIPTION: -
Pg-04
Assignment No.: 02
TOPIC: - Area and circumstances of circle.
Pg-05
Q2: Write a program to calculate the area and circumference of the
circle.
Solution:-
import java.io.*;
import java.util.*;
class Q2
{
area=pi*r*r;
circum=2*pi*r;
}//end main
}//end class
OUTPUT:-
VARIABLE DESCPRITION:-
NAME OF THE VARIABLE DATATYPE PURPOSE
Pg-07
Q3 Write any program to enter any three real numbers and
calculate X where :
Solution:
import java.io.*;
import java.util.*;
class real_no
{
public static void main(String [] args)
{
float n,x,pro_i=1,sum=0.0f;
int i;
Scanner ob=new Scanner(System.in);
for(i=1;i<=3;i++)
{
System.out.print("\nEnter "+1+" th no ");
n=ob.nextFloat();
pro_i*=(int)n;
sum+=n-(int)n;
}
x=pro_i/sum;//mant((float)n-(int)n));
System.out.print("\nResultant "+x);
return;
}
};
Pg-08
OUTPUT:-
Enter 1 th no 1
Enter 1 th no 85
Enter 1 th no 58
Resultant Infinity
VARIABLE DESCRIPTION:-
Pg-09
Assignm
ent No.: TOPIC: -Divisible by 5 or not
04
Pg-10
Q4 :- Write a program to check whether the
number is divisible by 5 or not.
SOLUTION:-
import java.util.*;
class Q4_
{
public static void main(String[]args)
{
int i;
Scanner ki=new Scanner(System.in);
System.out.print(" Enter the no.");
i=ki.nextInt();
if (i%5==0)
System.out.print(i+" the number is divisible by 5");
else
System.out.print(i+" the number is not divisible by 5");
return;
}
}
OUTPUT:-
Enter the no.25
25 the number is divisible by 5
VARIABLE DESCRIPTION:-
Pg-11
Assignm
ent No.: TOPIC: -Divisible by 5 or not
05
Pg-12
Q5 Write a program to input the basic salary of a person. He or she
get 15%of the basic as HRA, 15% of the basic as Convenience
allowances and 10% of the basic as medical allowances. The total
salary is calculated by adding basic +HRA +Convenience
allowances + medical allowances. Calculate and print the total
salary of the person.
Solution:-
import java.util.*;
class Q5
{
public static void main(String[]args)
{
float i, HRA, CA, MA, TS;
Scanner ki= new Scanner(System.in);
System.out.print("Enter the basic salary");
i=ki.nextFloat();
HRA=15/100*i;
CA=15/100*i;
MA=10/100*i;
TS=i+HRA+CA+MA;
System.out.print("total salary= "+TS);
}
}
OUTPUT:-
Enter the basic salary8000
Total salary= 8000.0
VARIABLE DESCRIPTION:-
06
Pg-14
Q6)Write a programme to enter the three sides of triangle. Decide
whether it is a scalene, isosceles or equilateral triangle.
Solution:-
import java.util.*;
class Q6{
public static void main (String [] args){
int a, b, c;
Scanner ki= new Scanner (System.in);
System.out.print ("\n Enter the three number");
a=ki.nextInt();
b=ki.nextInt();
c=ki.nextInt();
if(((a+b)>c)&&((a+c)>b)&&((b+c)>a)){
System.out.print ("it forms an Triangle");
if((a==b)&&(b==c))
System.out.print ("Equilateral Triangle");
if((a==b)&&(b==c))
System.out.print ("\nIsosceles Triangle");
else
System.out.print ("\nScalene Triangle");
}
else
System.out.print ("\nCannot form a Triangle");
return;
}
};
OUTPUT:-
Enter the three number
7
4
5
It forms an Triangle
Scalene Triangle
VARIABLE DESCRIPTION:-
07
Pg-16
Q7)A library charges fine for book returned late.Following are the
fines. First five days 2 rupees per day six to ten days 5
rupees,above 10 days 10 rupees per day.Design a programme to
calculate the fine assuming that a book is returned N days late.
Solution:-
import java.util.*;
class Q7{
public static void main (String[]args){
int n;
Scanner ki=new Scanner (System.in);
System.out.print ("Enter the no. of days ");
n=ki.nextInt();
if (n<=5)
System.out.print("You have to pay"+ (n*2)+"rupees”");
else if ((n>6)&&(n<=10))
System.out.print("You have to pay"+ (n*5)+"rupees");
else if (n>10)
System.out.print("You have to pay"+(n*10)+"rupees");
return;
}
};
OUTPUT:-
Enter the no. of days 5
You have to pay 10 rupees.
VARIABLE DESCRIPTION:-
Pg-17
Assignment No.:08
IC: -
Calculating the grade
Pg-18
Q8)Using if-else statements write a programming to calculate the
grade as per the given criteria.
Marks. Grade
>=80 and <100 Excelent
>=70 and <80 1st Div
>=60 and <70 2nd Div
>=50 and <60 3rd Div
Less then 50 Passed under considered.
Solution:-
import java.io.*;
import java.util.*;
class Q8{
public static void main(String[]args)
{
int i;
if((i>=80)&&(i<=100))
System.out.print("\n Excellent ");
else if((i>=70)&&(i<80))
System.out.print("\n First div. ");
else if((i>=60)&&(i<70))
System.out.print("\n Second div. ");
else if((i>=50)&&(i<=60))
System.out.print("\n Third Div. ");
else if(i<50)
System.out.print("\n Passed under consideration ");
};
Pg-19
OUTPUT:-
Enter the marks of the student 0
First div.
VARIABLE DESCRIPTION:-
Pg-20
Assignm
ent TOPIC: -Automorphic Number
No.:09
Pg-21
Q9)Write a programme to display Automorphic Number.
Solution:-
import java.io.*;
import java.lang.*;
class automorphic_series
{
public static void main(String [] args) throws IOException
{
int a,i,s,st,p;
for(s=1;;s++)
{
st=s;
for(i=0;st!=0;st/=10,i++);
p=i-1;
a=s*s;
for(;i>=0;a/=10,i--)
st+=(a%10)*Math.pow(10,p--);
if(st==s)
System.out.println(st);
}
}
public static int getint() throws IOException
{
BufferedReader ki=new BufferedReader(new InputStreamReader(System.in));
return(Integer.parseInt(ki.readLine()));
}
Pg-22
OUTPUT:-
1
5
6
963
9867
90629087
233930550
VARIABLE DESCRIPTION:-
Pg-23
A
ssignme Topic: - Disarium number
nt
No.:10
Pg-24
10) Write a programme to accept a number and check whether it is
a Disarium Number or not.
Solution:-
import java.util.*;
class disarium_no{
public static void main(String [] args)
{
int n,d,st,sum;
Pg-25
Output:-
Enter a no 1
1 is a diserium no.
Enter a no 548
548 is not a diserium no.
VARIABLE DESCRIPTION:-
Pg-26
Assignm
ent No.: Topic:- Even number series
11
Pg-27
import java.util.*;
class Q11{
public static void main(String [] args)
{
int i,n,s=0;
Scanner ki=new Scanner(System.in);
System.out.print("\nEnter the value of s \n");
n=ki.nextInt();
for (i=2;i<=n;i++){
if (i%2==0)
s+=i;
}
System.out.print (s);
return;
}
};
Output:-
Enter the value of s
41
420
Variable description:-
Pg-28
Assignm
ent No.:
Topic- *
12 ***
******
*********
******
***
*
Pg-29
Pg-30
Output:-
the output is *
***
*****
*******
*********
*******
*****
***
*
Variable description :-
Pg-31
Assignm
ent No.: Topic:- 11111
13 3333
555
77
9
Pg-32
13) Write a programme to display the given number pattern.
11111
3333
555
77
9
Solution:-
class Q13{
public static void main(String [] args)
{
int i,j,k;
for(i=5,k=1;i>=1;i--,k+=2){
for(j=1;j<=i;j++){
System.out.print(k);
}
System.out.println();
}
}
};
output:-
11111
3333
555
77
9
Variable Description:-
Pg-34
14)Write a programme to find the sum of Frist 20 terms of the
series.
S= (2/3) + (4/5) + (8/7) + (16/9) +.............
Solution: -
import java.util.*;
class Q14 {
public static void main (String [] args) {
float i,j,s=0.0f,m;
Scanner ki= new Scanner (System.in);
System.out.print (“enter the value of m”);
m=ki.nextFloat();
for (i=2,j=3.0f;i<=m;i*=2,j+=2)
{
s+=i/j;
}
System.out.print (“\n the result is “+s);
return;
}
}
Output:-
Variable Description:-
Pg-35
Assignment No.: 15
Topic:-Reverse array
Pg-36
Q15)Write a program to accept 10 integers in an array and print
the reverse array
Solution:-
importjava.util.*;
class Q15reverse_array{
public static void main(String [] args)
{int i;
int []ar=new int[10];
Scanner ki=new Scanner(System.in);
System.out.print("\nEnter int s");
for(i=0;i<10;i++){
ar[i]=ki.nextInt();
}//collecting values
System.out.println("\nPrinting array in reverse order");
for(i=9;i>=0;i--){
System.out.print(ar[i]+"\t");
}//collecting value
return;
}
};
Pg-37
OUTPUT:-
Enter int s
14
12
5
3
6
5
463
45
42
45
Pg-38
Assignment No.: 16
Topic:-Merging array
Pg-39
16)Write a program to declare an integer array to accept 6
elements, another array to store 4 elements. Merge both the arrays
and print the values in a third array.
SOLUTION:-
import java.util.*;
class Q16{
public static void main(String [] args){
int i,j,k;
Scanner ki=new Scanner(System.in);
int [] a=new int[6];
int [] b=new int[4];
int []c=new int[10];
System.out.println("Enter 6 values for the first array ");
for(i=0;i<6;i++) {
System.out.print("\nEnter "+(i+1)+"-th value ");
a[i]=ki.nextInt();
}//end for
System.out.println("Enter 4 values for the second array ");
for(j=0;j<4;j++){
System.out.print("\nEnter "+(j+1)+"-th value ");
b[j]=ki.nextInt();
}//end for
for(i=0,k=0;i<6;i++,k++) {
c[k]=a[i]; }
for(j=0;j<4;j++,k++)
{c[k]=b[j];
}
System.out.print("\nThe merged array is \n");
for(k=0;k<10;k++){
System.out.print(c[k]+" ");}
return;}
};//end class
Pg-40
OUTPUT:-
Enter 1-th value 1
Variable Description:-
Pg-41
Assignment No.: 17
Topic:- i) Largest and the smallest element.
ii) Product of odd numbers.
iii) Sum of the even numbers.
Pg-42
17)Write a Program to find from the following
data:17,20,24,29,16,87,19,52.
i) The largest and smallest element ;
ii) Product of the odd number ;
iii)Sum of the even numbers.
SOLUTION:-
import java.util.*;
class Q17X{
public static void main(String [] args)
{
int i,large,small,pro=1,sum=0;
int [] a={17,20,24,29,16,87,19,52};
large=a[0];
small=a[0];
for(i=0;i<a.length;i++) {
if(a[i]>large)
large=a[i];
if(a[i]<small)
small=a[i];
if(a[i]%2==1)
pro*=a[i];
else
sum+=a[i];
}
}
}
Pg-43
OUTPUT:-
Variable Description:-
Pg-44
Assignment No.: 18
Topic:-i) Number of word present in the sentence
ii) number of letter present in the sentence
Pg-45
18) Write a program to input a sentence. Find and display the
following :
i) Number of words present in the sentence.
ii)Number of letters present in the sentence.
Assume that the sentence has neither include any digit following
nor a special character.
Solution :-
import java.util.*;
class word_sentences{
public static void main(String [] args)
{
String s;
int i,b;
Scanner ki=new Scanner(System.in);
System.out.print("\nEnter a sentence [DON\'T PUT . OR ? AT THE END OF THE
SENTENCE ]");
s=ki.nextLine();
for(i=0,b=0;i<s.length();i++)
{
if(s.charAt(i)==' ')
b++;//counting blank spaces
}//end for
/In a sentence no of words are 1 more than no of blankspaces/
/"I LOVE INDIA" the sentence has 2 blanks while 3 no of words/
Pg-46
OUTPUT:-
Enter a sentence [DON'T PUT . OR ? AT THE END OF THE SENTENCE ]
I love my school
1. No of words 5 and
2. The no of letters present in the sentence is 13
Variable Description:-
Pg-48
SOLUTION:-
class removal_of_vowels
{
public static void main(String[]args)throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a String:");
StringBuffer s =new StringBuffer(br.readLine().toLowerCase());
int i;
for(i=0;i<s.length();i++)
{
if((s.charAt(i)=='a')||(s.charAt(i)=='e')||(s.charAt(i)=='i')||(s.charAt(i)=='o')||
(s.charAt(i)=='u')){
s.deleteCharAt(i);
--i;}//end if
}//end for
System.out.print(s);
return;
}//end main
};//end class
Pg-49
Output:-
Enter a String:
Bhishop Morrow
bhshp mrrw
Variable Description:-
Pg-50
Assignment No.: 20
Topic:-To enter a string or sentence and display the longest word
and the length of the longest word
Pg-51
20) Write a program in JAVA to enter a string/ sentence &
display the longest word and the length of the longest word
present in the string.
Sample Input :"TATA FOOTBALL ACADEMY WILL PLAY
AGAINST MOHON BAGAN".
Sample Output : The longest word :FOOTBALL
The length of the word: 8
SOLUTION:-
import java.io.*;
import java.lang.*;
import java.util.*;
class longest_word
{
public static void main(String [] args)
{int i=0,max=0;
Scanner ki=new Scanner(System.in);
String s,st1 ="";
for(i=0;i<ar.length;i++)
{
if(ar[i].length()>max)
{
max=ar[i].length();
st1=ar[i];
}
}//end for
return;
}
};
Pg-52
Output:-
Enter the string to find out the longest word =>TATA FOOTBALL ACADEMY PLAYED
AGAINST MOHAN BAGAN.
The longest word FOOTBALL has 8 characters.
Variable Description:-
Pg-53
Conclusion
Java has significant advantages not only as a commercial
language but also as a teaching language. It allows students
to learn object-oriented programming without exposing
them to the complexity of C++. It provides the kind of
rigorous compile-time error checking typically associated
with Pascal. It allows instructors to introduce students to
GUI programming, networking, threads, and other
important concepts used in modern-day software.
Pg-54
Bibliography
ICSE Computer Application
APC Computer with BlueJ
www.kboat.com.
Pg-55
Declaration
Date: - 03/06/2022
Father-
Marks-
Marks-
Pg-56
Pg-57