You are on page 1of 8

SPICER HIGHER SECONDARY

SCHOOL

A Project submitted in the partial fulfillment of the required subject :


Computer

Name : Karan Anand Gandhi


Class : IX – B
Roll No. : 31
Submitted to : Kingsly Sir
-------------------------------
---------------------------------

Sign Remarks

INDEX

1) Program 4.2 1

2) Program 5.9 2

3) Program 6.1 3

4) Program 7.1 4

5) Program 8.3 5
PROGRAM 4.2

Write a program to find the sum of three given numbers 1221, 2332, 3443.

public class Test


{
void myMethod()
{
int num1, num2, num3, sum;
num1 = 1221;
num2 = 2332;
num3 = 3443;
sum = num1 + num2 + num3
System.out.println(“3 given numbers are :”);
System.out.println(“num1”);
System.out.println(“num2”);
System.out.println(“num3”);
System.out.println(“Sum =” + sum);
}
}

OUTPUT
3 given numbers are:
1221
2332
3443
Sum = 6996

PROGRAM 5.9

Write a program to calculate area of a sphere with radius 7 cm.

public class Volume_SurfaceArea


{
public void calcArea()
{
int r = 7 ;
double area, volume, pi = 3.14159 ;
System.out.println(“Radius of sphere : ” + r);
area = 4 * pi * r * r ;
System.out.println(“Surface area of sphere” + area);
}
}

OUTPUT
Radius of sphere : 7
Surface Area of sphere : 615.75614
PROGRAM 6.1

Program to print cube of a number using a method.

public class First


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

OUTPUT
The cube of 7.5 is 421.875
PROGRAM 7.1

Program to illustrate the use of Date class for printing current Date/Time.

import.java.util.*;

class Dateplay
{
static public void DatePlay()
{
Date d = newDate();
System.out.println(“The date is” + d);
}
}

OUTPUT
The date is sat Feb 24 20:46:16 EST 2018
PROGRAM 8.3

Write a program that inputs the radius of a circle and finds its perimeter.

import.java.util.Scanner ;
public class Circle
{
void calc_perim()
{
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);
}
}
OUTPUT
Enter radius : 3.5
Perimeter of a circle is 21.991148575128552

You might also like