0% found this document useful (0 votes)
36 views26 pages

Rupsha CoP

1. The document is a computer project report submitted by Rupsha Dutta, a class 10 student from Modern Public School. 2. It includes an acknowledgement section thanking her computer teacher and others for their help and support. 3. The contents section lists 8 programming problems and their page numbers that Rupsha has solved for the project.
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)
36 views26 pages

Rupsha CoP

1. The document is a computer project report submitted by Rupsha Dutta, a class 10 student from Modern Public School. 2. It includes an acknowledgement section thanking her computer teacher and others for their help and support. 3. The contents section lists 8 programming problems and their page numbers that Rupsha has solved for the project.
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/ 26

Modern Public School

Computer Project
(2023-2024)
Name : Rupsha Dutta

Class : X Section : B
Roll No.: 33

Page | 1
Acknowledgement
I would like to express my special thanks of gratitude to my computer
teacher Prantik Nandy , who gave me the golden opportunity to do
this wonderful assignment. I came to know so many new things, I am
really thankful to them. Secondly, I would like to thank my parents,
teachers and friends who helped me a lot in finishing this program
neatly, tidily and within the limited time frame.
Thank You,
Rupsha Dutta

Page | 2
Contents
Topic Page no.
1. Write a java program to interchange two numbers in a sub method where 5-6
both input and output will be done in sub.
2. Write a program based on the criteria given below and input the name 7-9
and address of the customer and the type of purchase (L for laptop and D for
desktop PC). Compute the net amount to be paid by the customer.
Purchase amount discount on laptop discount on desktop PC
0-25000 0.0% 5.0%
25001-57000 5.0% 7.5%
57001-100000 7.5% 10.0%
More than 100000 10.0% 15.0%
3. Write a program to add the following series using the members given 10-12
below:
Ax-ax2+ax3-ax4…..upto n terms
Name of the class: Series
Member data: s:to store the sum
Member method: Series():to initialize s as 0
Void ask():to ask a,x and n
Void call():to add the series
Void display():to show the sum
4. Write a java program to check whether a given character is an uppercase 13-14
or lowercase or digit.
5. Write a java program to check whether a number is prime or not using a 15-16
method which will take input from main().
6. Write a program to convert Fahrenheit to Centigrade or Centigrade to 17-19
Fahrenheit as per user’s choice. Design two methods separately to perform
two tasks which will take value from the main().
7. Write a program to accept a number from the user and check if it is an 20-21
automorphic number or not.
8. Write a program to create overloaded methods named void 22-24
calc_volume(), that has been overloaded to perform the following functions:
Volume of Sphere
Volume of Cylinder
Volume of Cone
Write a menu driven program in java to display the above 3 menus
and execute the overloaded methods and display the volume in the
respective functions.
calc_volume(double) for sphere
calc_volume(double,double) for cylinder and
calc_volume(float,float) for cone.

Page | 3
Introduction
Java is a popular third generation programming language that can
handle any kind of software emerging in the computer background.
Java is an Object-oriented programming language. The features and
the kind of functionality and versatility java offers, has contributed, to
a large degree, to the popularity of this language.
In the early nineties, java was created by a team led by James
Gosling, for Sun Microsystems, later acquired by Oracle Corporation
that provides a system for developing application software. It was
originally designed for use on digital mobile devices, such as cell
phones. However, when java 1.0 was released in 1996, its main focus
shifted to use on the internet. It provided more interactivity with users
by giving developers a way to produce animated web pages.

Page | 4
Programs with output
1. Write a java program to interchange two numbers in a sub
method where both input and output will be done in sub.

 The Program:
import java.util.*;

public class program1

void sub()

Scanner sc= new Scanner(System.in);

System.out.println("Enter two numbers for inter changing");

int x= sc.nextInt();

int y= sc.nextInt();

x=x+y;

y=x-y;

x=x-y;

System.out.println("Numbers after inter changing");

System.out.println(x);

System.out.println(y);

public static void main()

program1 obj= new program1();

obj.sub();

Page | 5
Output:

Variable description box:


Variable name Data type Purpose
sc object Object of Scanner class.
x integer To store a value from user.
y integer To store a value from user.
obj object Object of the class.

Page | 6
2. Write a program based on the criteria given below and input the
name and address of the customer and the type of purchase (L for
laptop and D for desktop PC). Compute the net amount to be paid by
the customer.
Purchase amount discount on laptop discount on desktop PC
0-25000 0.0% 5.0%
25001-57000 5.0% 7.5%
57001-100000 7.5% 10.0%
More than 100000 10.0% 15.0%

 The Program:
import java.util.*;

public class program2

public static void main()

Scanner sc= new Scanner(System.in);

System.out.println("Enter the name");

String name= sc.nextLine();

System.out.println("Enter the address");

String add= sc.nextLine();

System.out.println("Enter the type of purchase");

char type= sc.next().charAt(0);

double dis,net,pur;

switch(type)

case 'L':

System.out.println("Enter the purchase amount of your laptop");

pur= sc.nextDouble();

if(pur<=25000)

dis= pur*0/100;

else if(pur>25000 && pur<=57000)

Page | 7
dis= pur*5/100;

else if(pur>57000 && pur<=100000)

dis= pur*7.5/100;

else

dis= pur*10/100;

net= (pur-dis);

System.out.println("Net amount payable= "+net);

break;

case 'D':

System.out.println("Enter the purchase amount of your desktop PC");

pur= sc.nextDouble();

if(pur<=25000)

dis= pur*5/100;

else if(pur>25000 && pur<=57000)

dis= pur*7.5/100;

else if(pur>57000 && pur<=100000)

dis= pur*10/100;

else

dis= pur*15/100;

net= (pur-dis);

System.out.println("Net amount payable= "+net);

break;

default:

System.out.println("Wrong type of purchase");

Page | 8
Output:

Variable description box:


Variable name Data type Purpose
sc object Object of scanner class.
name,add String Stores data from the user.
type character Stores data from the user.
dis,net,pur double To calculate and store value.

Page | 9
3. Write a program to add the following series using the members given
below:
Ax-ax2+ax3-ax4…..upto n terms
Name of the class: Series
Member data: s:to store the sum
Member method: Series():to initialize s as 0
Void ask():to ask a,x and n
Void call():to add the series
Void display():to show the sum

 The Program:
import java.util.*;

public class Series

Scanner sc= new Scanner(System.in);

double a;

double x;

double n;

double s;

void series()

s=0;

void ask()

System.out.println("Enter the value of a");

a= sc.nextInt();

System.out.println("Enter the value of x");

x= sc.nextInt();

Page | 10
System.out.println("Enter the value of n");

n= sc.nextInt();

void call()

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

if(i%2==0)

s= s-(a*Math.pow(x,i));

else

s= s+(a*Math.pow(x,i));

void display()

System.out.println("Sum of the series= "+s);

public static void main()

Series obj= new Series();

obj.series();

obj.ask();

obj.call();

obj.display();

Page | 11
Output:

Variable description box:


Variable name Data type Purpose
sc object Object of Scanner class.
a,x,n double To calculate and store a
value from the user.
s double To calculate and store
the value of the series.
obj object Object of the class.

Page | 12
4. Write a java program to check whether a given character is
an uppercase or lowercase or digit.

 The Program:
import java.util.*;

public class program4

public static void main()

Scanner sc= new Scanner(System.in);

System.out.println("Enter a character");

char n= sc.next().charAt(0);

if(Character.isUpperCase(n))

System.out.println("The character is uppercase");

else if(Character.isLowerCase(n))

System.out.println("The character is lowercase");

else if(Character.isDigit(n))

System.out.println("The character is a digit");

else

System.out.println("The character is not lowercase,uppercase or a digit");

Page | 13
Output:

Variable description box:


Variable name Data type Purpose
sc object Object of Scanner class.
n character To store data from the
user.

Page | 14
5. Write a java program to check whether a number is prime
or not using a method which will take input from main().

 The Program:

import java.util.*;

public class program5

static boolean prime(int x)

int c=0;

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

if(x%i==0)

c= c+1;

if(c==2)

return true;

else

return false;

public static void main()

Scanner ss= new Scanner(System.in);

System.out.println("Enter a number");

int n= ss.nextInt();

boolean z= prime(n);

Page | 15
if(z==true)

System.out.println(n+" is a prime number");

else

System.out.println(n+" is not a prime number");

Output:

Variable description box:


Variable name Data type Purpose
x integer To perform tasks in method
prime().
c,i integer To calculate and store a
value.
ss object Object of the Scanner class.
n integer To store a value from the
user.
z boolean To perform some tasks.

Page | 16
6. Write a program to convert Fahrenheit to Centigrade or
Centigrade to Fahrenheit as per user’s choice. Design two
methods separately to perform two tasks which will take
value from the main().

 The Program:

import java.util.*;
public class program6
{
static double f_to_c(double f)
{
double c= ((f-32)*5)/9;
return c;
}
static double c_to_f(double c)
{
double f= (c*9/5)+32;
return f;
}
public static void main()
{
Scanner sc= new Scanner(System.in);
System.out.println("Enter 1 to convert temperature from Fahrenheit to
Centrigrade scale");
System.out.println("Enter 2 to convert temperature from Centrigrade to
Fahrenheit scale");
int choice = sc.nextInt();
double f;
double c;

Page | 17
switch(choice)
{
case 1:
System.out.println("Enter the temperature in Fahrenheit scale");
f= sc.nextDouble();
c= f_to_c(f);
System.out.println("The temperature in Centrigrade scale= "+c);
break;
case 2:
System.out.println("Enter the temperature in Centrigrade scale");
c= sc.nextDouble();
f= c_to_f(c);
System.out.println("The temperature in Fahrenheit scale= "+f);
break;
default:
System.out.println("Wrong choice");
}
}
}

Output:

Page | 18
Variable description box:
Variable name Data type Purpose
f,c double To store a data from the
user. To perform certain
tasks and calculations in
c_to_f() , f_to_c() and
main() methods.
sc object Object of the Scanner
class.
choice integer To store a data from the
user.

Page | 19
7. Write a program to accept a number from the user and check if it is
an automorphic number or not.

 The Program:
import java.util.*;

public class program7

static boolean Auto(int n)

int sq= n*n;

while(n>0)

if(n%10 != sq%10)

return false;

n=n/10;

sq=sq/10;

return true;

public static void main()

Scanner sc= new Scanner(System.in);

System.out.println("Enter the number");

int n= sc.nextInt();

System.out.println(Auto(n)?"Automorphic number":"Not Automorphic number");

Page | 20
Output:

Variable description box:


Variable name Data type Purpose
n integer To store a value from the
user. To calculate and
perform tasks in Auto()
and main() methods.
sq integer To calculate and store a
value.
sc object Object of the Scanner
class.

Page | 21
8. Write a program to create overloaded methods named void
calc_volume(), that has been overloaded to perform the following
functions:
Volume of Sphere
Volume of Cylinder
Volume of Cone
Write a menu driven program in java to display the above 3 menus
and execute the overloaded methods and display the volume in the
respective functions.
calc_volume(double) for sphere
calc_volume(double,double) for cylinder and
calc_volume(float,float) for cone.

 The Program:
import java.util.*;
public class program8
{
double vol;
double pi= 3.14159265359;
void calc_volume(double r)
{
vol= (4*pi*Math.pow(r,3))/3;
System.out.println("Volume of the sphere= "+vol);
}
void calc_volume(double r, double h)
{
vol= pi*Math.pow(r,2)*h;
System.out.println("Volume of the cylinder= "+vol);
}
void calc_volume(float r, float h)
{
vol= pi*Math.pow(r,2)*(h/3);

Page | 22
System.out.println("Volume of the cone= "+vol);
}
public static void main()
{
Scanner sc= new Scanner(System.in);
program8 obj= new program8();
System.out.println("Enter 1 to compute the volume of a sphere");
System.out.println("Enter 2 to compute the volume of a cylinder");
System.out.println("Enter 3 to compute the volume of a cone");
int choice= sc.nextInt();
switch(choice)
{
case 1:
System.out.println("Enter the radius of the sphere");
double r= sc.nextDouble();
obj.calc_volume(r);
break;
case 2:
System.out.println("Enter the radius of the cylinder");
double r1=sc.nextDouble();
System.out.println("Enter the height of the cylinder");
double h= sc.nextDouble();
obj.calc_volume(r1,h);
break;
case 3:
System.out.println("Enter the radius of the cone");
float r2= sc.nextFloat();
System.out.println("Enter the height of the cone");
float h2=sc.nextFloat();

Page | 23
obj.calc_volume(r2,h2);
break;
default:
System.out.println("Wrong choice");
break;
}
}
}

Output:

Variable description box:


Variable name Data type Purpose
vol,r,h,r1 double To store a value from the
user. To calculate and
perform different tasks.
pi double To store the value of pi.
r,h,r2,h2 float To store a value from the
user. To calculate and
perform different tasks.
sc object Object of Scanner class.
obj object Object of the class.
choice integer To store a value from the
user.

Page | 24
Conclusion
Java is an object-oriented programming language. It is a general-
purpose programming language, mainly designed to run developed
java code on all platforms. With technology now a part of our daily
lives, we take it for granted that we can be connected to, and access
applications and content anywhere, anytime. Because of java, we
create digital devices which are smarter, more functional and far more
entertaining. Over the years, java has evolved as a successful
language for use, both on and off the internet. Till now, java is an
extremely popular language with millions of programmers worldwide.

Page | 25
Bibliography
Help from internet, websites and books have been used in the
completion of this program file:
Help from internet:
• https://google.com
Following books has been used to have an idea about the program:
• Frank Computer Applications for ICSE (class IX)
• Frank Computer Applications for ICSE (class X)
And help from teachers, parents and friends has also been taken to
finalize the program.

Page | 26

You might also like