Class 9 Computer Project
Class 9 Computer Project
APPLICATION 2021-2022
PROJECT
Submitted by Submitted to
1
ACKNOWLEDGEMENT
2
INDEX
Serial Number Topic Page Number
1. Introduction to Java 4
2. Introduction to BlueJ 5
3. BlueJ Programs 6-26
BlueJ Programs:-
Based On Programs Page Number Submission Date
Assignment Program to find the
cube of a given number 7 30.6.2021
Statement
Assignment Program to find out the
area and the perimeter 8 30.6.2021
Statement of a rectangle
Program to add to
Input Parameter numbers to print a 9 30.6.2021
result
Program to input four
Input Parameter names 10 30.6.2021
Input Through Program to print a
name and display a 11 31.6.2021
Scanner Class greeting
Input Through Program to calculate
the distance between 2 12 31.6.2021
Scanner Class points
Program to calculate
two numbers and
Mathematical display their squares,
cubes, square roots and 13 31.7.2021
Method
cube roots.
Program to read an
integer and check
If Else If Ladder whether it is an even 16 31.7.2021
number or odd
number.
3
Program that reads the
month number and
Switch-Case tells the number of days 17-18 31.8.2021
in the month
Program to input
number of week‟s
day(1-7) and translate to
Switch-Case its equivalent name of 19 31.8.2021
the day of the week.
Program to calculate
simple interest for any
principal amount, with
Menu-Driven rate as 7.2% and time as 20 31.8.2021
3 years.
Program to convert
temperature 98.6°F into
Menu-Driven degree Celsius. 21 31.8.2021
Program to find
whether given number
Loop is Armstrong or not.
22 31.10.2021
Generating first
n Multiples of
Numbers from Program to check and
1 to the Limit print multiple of 2. 27 31.12.2021
Input by the
User
4
Introduction to Java
Java is a high-level programming language originally developed by Sun
Microsystems and released in 1995. Java runs on a variety of platforms, such as
Windows, Mac OS, and the various versions of UNIX. This tutorial gives a
complete understanding of Java. This reference will take you through simple and
practical approaches while learning Java Programming Language.
5
Introduction to BlueJ
BlueJ is an integrated development environment (IDE) for the Java programming
language, developed mainly for educational purposes, but also suitable for small-
scale software development. It runs with the help of JDK(Java Development Kit).
Blue-J was developed to support the learning and teaching of object-oriented
programming, and its design differs from other development environments as a
result. The main screen graphically shows the class structure of an application
under development (in a UML-like diagram), and objects can be interactively
created and tested. This interaction facility, combined with a clean, simple user
interface, allows easy experimentation with objects under development. Object-
oriented concepts (classes, objects, communication through method calls) are
represented visually interaction design in the interface.
6
Programs in BlueJ
ASSIGNMENT 1
Assignment Statement
Q1) Write a program to print the cube of a given number using a
method.
// To print the cube of a number.
public class First {
public static float cube(float a) {
float n= a*a*a ;
return n ;
}
public void FirstTest() {
float x= 7.5f, y=0 ;
y= cube(x) ;
System.out.println(“The cube of” + x + “is” + y) ;
}
}
List of Variables
Name of the variables Data Type Description/Purpose
n float To input first variable
x float To input first number
y float To input second number
7
Q2) Write a program to find out the area and the perimeter of a
rectangle.
// To print the area and the perimeter of the rectangle.
public class Rectangle {
double length, breadth ;
double area, perimeter ;
public static void getValues(double l, double b) {
length = l;
breadth = b;
}
double calcArea() {
double a= length*breadth;
area = a ;
return a;
}
double calcPerimeter() {
double p= 2*(length=breadth);
perimeter = p;
return p;
}
}
List of Variables
Name of the variables Data Type Description/Purpose
l double To input first variable
b double To input second variable
a double To input third variable
p double To input fourth variable
8
ASSIGNMENT 2
Input Parameters
List of Variables
Name of the variables Data Type Description/Purpose
x int To input first number
y int To input second number
9
Q2) How to enter four names.input parameter.
// To print four names.
public class Main {
public static void myMethod(String fname, int age) {
System.out.println(fname + “is” + age) ;
}
public static void main(String [] args) {
myMethod(“John”, 5) ;
myMethod(“Mary”, 8) ;
myMethod(“Anja”, 30) ;
myMethod(“Sam”, 25) ;
}
}
List of Variables
Name of the variables Data Type Description/Purpose
age int To input first variable
10
ASSIGNMENT 3
Input through Scanner class
Q1) Write a program to take your name as input from user through
keyboard and display a greeting.
//To print a name and display a greeting.
import Java.util.Scanner;
public class Input {
public static void takeInput() {
double n1, n2, n3, sum, avg;
Scanner sc = new Scanner (System.in);
System.out.println(“Enter 3 numbers :”);
n1 = sc.nextDouble ();
n2 = sc.nextDouble ();
n3 = sc.nextDouble ();
sum = n1+n2+n3;
avg = sum/3;
System.out.println(“You entered :” + n1+ “,” +n2+ “,” +n3+ );
System.out.println(“Their average is =” + avg);
}
}
List of Variables
11
Q2) Write a program to calculate the distance between 2 points (x1,x1)
and (x2,y2).
// To calculate the distance between 2 points.
import Java.util.Scannner;
public class Distance{
void calcDist(){
int x1,y1,x2,y2;
double dist= 0;
Scanner sc = new Scanner(System.in);
System.out.println(“Enter two coordinates for point 1 (x1,y1) :”);
System.out.println(“Enter x1 :”);
x1 = sc.nextInt();
System.out.println(“Enter y1 :”);
y1 = sc.nextInt();
System.out.println(“Enter two coordinates for point 2 (x2,y2) :”);
System.out.println(“Enter x2 :”);
x1 = sc.nextInt();
System.out.println(“Enter y2 :”);
y1 = sc.nextInt();
dist = Math.sqrt(Math.pow(x2-x1,2) + Math.pow(y2-y1,2));
System.out.println(“The distance between these two given points is
:” +dist);
}
}
List of Variables
12
ASSIGNMENT 4
Mathematical Methods
Q1) Write a program to read two numbers and display their squares,
cubes, square roots and cube roots.
//To print the square, cube, square root and cube root of a number.
import Java.util.Scanner;
public class powerRoots
{
public static void compute(){
Scanner sc=new Scanner(System.in);
int num1, num2;
System.out.println(“Enter first integer number:”);
num1=sc.nextInt();
System.out.println(“Enter second integer number:”);
num2=sc.nextInt();
System.out.println(“Square of”+num1+“is:”+ Math.pow(num1,2));
System.out.println(“Square of”+num2+“is:”+ Math.pow(num2,2));
System.out.println(“Cube of”+num1+“is:”+ Math.pow(num1,3));
System.out.println(“Cube of”+num2+“is:”+ Math.pow(num2,3));
System.out.println(“Square Root of”+num1+“is:”+ Math.sqrt(num1));
System.out.println(“Square Root of”+num2+“is:”+ Math.sqrt(num2));
System.out.println(“Cube Root of”+num1+“is:”+ Math.cbrt(num1));
System.out.println(“Cube Root of”+num2+“is:”+ Math.sqrt(num2));
}
}
List of Variables
13
Q2) Write a program that inputs radius of a circle and finds its
perimeter.
//To print the radius of a circle in order to find its perimeter.
import Java.util.Scanner;
public class Circle {
public static void calc_perimeter() {
double radius, perimeter;
Scanner sc= new Scanner(System.in);
System.out.println(“Enter radius:”);
radius= sc.nextDouble();
perimeter= 2*Math.PI*radius;
System.out.println(“Perimeter of a circle is ”+ perimeter);
}
}
List of Variables
14
ASSIGNMENT 5
If Else If Ladder
Q1) Write a program to compare two given numbers and display which
of them is greater or whether they are equal.
// To print whether two given numbers are greater or equal.
15
Q2) Write a program to read an integer and check whether it is an
even number or odd number.
//To print whether an integer is an even or odd number.
import Java.util.Scanner;
public class Numbers{
public static boolean testEven(int n){
if(n%2==0)
return true;
else return false;
}
public static void main(String[]args){
Scanner sc = new Scanner(System.in);
int number;
System.out.println(“Enter an integer : ”);
number = sc.nextInt();
if (testEven(number)==true)
System.out.println(number + “is an EVEN number”);
else
System.out.println(number + “is an ODD number”);
}
}
List of Variables
Name of Variables Data Type Description/Purpose
To give the user to input an
number int integer
16
ASSIGNMENT 6
Switch-Case
Q1) Write a program that reads the month number and tells the
number of days in the month.
// To read the month number and tell the number of days in the
month.
import Java.util.Scanner;
class MonthsandYears {
public static void main(String[]args) {
int month, year, numDays=0;
18
Q2) Write a program to input number of week‟s day(1-7) and translate
to its equivalent name of the day of the week.
// To input number of week‟s day(1-7) and translate to its equivalent
name of the day of the week.
public class Days{
public static void Weekday(int dow){
String ans;
switch(dow)
{
case 1: ans= “SUNDAY”; break;
case 2: ans= “MONDAY”; break;
case 3: ans= “TUESDAY”; break;
case 4: ans= “WEDNESDAY”; break;
case 5: ans= “THURSDAY”; break;
case 6: ans= “FRIDAY”; break;
case 7: ans= “SATURDAY”; break;
default: ans= “WRONG DAY NUMBER”;
}
System.out.println(“Day no. ”+dow+ “ is ”+ans);
}
}
List of Variables
Name of Variables Data Type Description/Purpose
dow int To input weekday number
To print day name of the
ans string week according to the
number
19
ASSIGNMENT 7
Menu Driven
Q1) Write a program to calculate simple interest for any principal
amount, with rate as 7.2% and time as 3 years.
// To calculate simple interest for any principal amount, with rate as
7.2% and time as 3 years.
public class SimpleInterest{
public static void calcSimplInt(){
double p= 5500, r= 7.2, t=3;
double si=0;
// Formula of simple interest
si = (p*r*t)/100;
System.out.println(“Simple Interest is : ”+si+“\n”);
}
}
List of Variables
Name of Variables Data Type Description/Purpose
p double To input principal amount
r double To input rate of interest
To input the time for which
t double the principal amount is to be
deposited
To print out the simple
si double interest each year on the
principal amount
20
Q2) Write a program to convert temperature 98.6°F into degree
Celsius.
// To convert temperature 98.6°F into degree Celsius.
public class TempConversion {
public static void tempConvFtoC(){
double Fahrenheit= 98.6;
double Celsius;
Celsius = (5*(Fahrenheit-32)/9);
System.out.println(“The Fahrenheit degree ”+Fahrenheit+“ is
”+Celsius+“in Celsius.” );
}
}
List of Variables
Name of Variables Data Type Description/Purpose
To input the value of
Fahrenheit double Fahrenheit scale to be
converted into Celsius scale
To find the value of the given
Celsius double value of Fahrenheit scale in
Celsius scale
21
ASSIGNMENT 8
Loops
Q1) Write a program to find whether given number is Armstrong or
not.
// To find whether given number is Armstrong or not.
import java.util.Scanner ;
public class Armstrong {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in) :
System.out.print(“Enter a 3 digit number to be checked : ”) ;
int num = sc.nextInt( ) ;
int n = num ;
int check = 0, remainder ;
do {
remainder = n % 10 ;
check = check + (int)Math.pow(remainder,3) ;
n = n / 10 ;
} while(n != 0) ;
if(check == num) // if sum of cubes is equal to number
System.out.println(num + “ is an Armstrong Number”) ;
else
System.out.println(num + “ is not an Armstrong Number”) ;
}
}
List of Variables
Name of Variables Data Type Description/Purpose
To allow the user to input a 3 digit
number and use it to find whether
num/n int the number is an Armstrong
number or not
To find the powered value of all the
check int individual numbers of the 3 digit
number inputed by the user
To find the remainder of the
remainder int inputed 3 digit number by user
22
Q2) Write a program to print first 10 powers of 2.
// To print first 10 powers of 2.
public class Powers {
public static void prnPowers() {
int i, n=2, pwr=2 ;
for(i=1; i<=10; i++,pwr*=2)
{
System.out.println(n+“^”+i+“ = ”+pwr) ;
}
}
}
List of Variables
Name of Variables Data Type Description/Purpose
i int To initialize the program
To type the value of the
number(here 2), whose
n int powers upto 10 we are going
to print
To find the resultant value of
pwr int the number(here 2) with the
powers of upto 10
23
ASSIGNMENT 9
Nested Loops
Q1) Write a program to print a table of multiplication tables of 1 to 10.
// To print a table of multiplication tables of 1 to 10.
public class Mult_Table
{
public static void printMult_Tables()
{
int i, j ;
for( i=1 ; i<=10 ; i++)
{
for( j=1 ; j<=10 ; j++)
{
System.out.print(( i*j )+ “\t”) ;
}
System.out.println( ) ;
}
}
}
List of Variables
Name of Variables Data Type Description/Purpose
To control the outer loop i.e.,
i int control the given
input(number for tables)
To control the inner loop i.e.,
control the line for the given
j int input(line/spaces for the
tables to be written clearly)
24
Q2) Write a program to print a pattern as shown below :
****1
***2*
**3**
*4***
5****
// To print the above pattern
public class Pattern
{
public static void main( )
{
int NOL = 5 ;
for ( int line =1 ; line<=5 ; line++)
{
for (int j =1 ; j<= (NOL-line) ; j++)
{
System.out.print(“*”);
}
System.out.println(line);
}
}
}
List of Variables
Name of Variables Data Type Description/Purpose
To input the maximum
NOL int number upto which the given
pattern has to be printed
To control the outer loop i.e.,
line int control the given input(here
pattern)
To control the inner loop i.e.,
control the line for the given
j int input(line/spaces for the
pattern to be written clearly)
25
ASSIGNMENT 10
Generating first n Multiples of Numbers from 1 to the Limit Input by
the User
Q1) Write a program to check and print multiple of 5.
// To print a program to check and print multiple of 5.
public class TheMultipleOf5 {
public static void main(String[]args){
System.out.println(“Multiple of 5 are : ”);
for(int number = 0; number< 50; number++){
if(number%5==0) {
System.out.print(number+ “ ”);
// check if number is multiple of 5
}
}
}
List of Variables
Name of Variables Data Type Description/Purpose
To give the mulriplied
number int
number till 50.
26
Q2) Write a program to check and print multiple of 2.
// To print a program to check and print multiple of 2.
public class TheMultipleOf2 {
public static void main(String[]args){
System.out.println(“Multiple of 2 are : ”);
for(int number = 0; number< 20; number++){
if(number%2==0) {
System.out.print(number+ “ ”);
// check if number is multiple of 2
}
}
}
List of Variables
Name of Variables Data Type Description/Purpose
To give the mulriplied
number int
number till 20.
27
BIBLIOGRAPHY
I have taken help from some of the books and websites in order to
complete the project successfully. These are:-
Class IX Computer Applications- by Sumit Arora
https://www.tutorialandexample.com
CONCLUSION
Java programming plays a significant role in the field of computer.
These programming languages help us to make a computer software
easily and efficiently. It helps us to give orders or commands to the
computer and also helps to make apps. Thus, we need to use
programming languages efficiently in order to improve contaction
between humans and this computerized and technological world.
THE END
28