Class 10 Computer Project Solve 2022
Class 10 Computer Project Solve 2022
(a) void series (int x, int n) – To display the sum of the series given below:
x1 + x2 + x3 + ……………. xn term
(b) void series (int p) – To display the following series:0, 7, 26, 63 p terms.
(c) void series () – To display the sum of the series given below:
1/2+1/3+1/4.....1/10
CODE:
Import java.util.*;
public class KboatOverloadSeries
{
void series(int x, int n) {
long sum = 0;
for (int i = 1; i <= n; i++) {
sum += Math.pow(x, i);
}
System.out.println("Sum = " + sum);
}
void series(int p) {
for (int i = 1; i <= p; i++) {
int term = (int)(Math.pow(i, 3) - 1);
System.out.print(term + " ");
}
System.out.println();
}
void series() {
double sum = 0.0;
for (int i = 2; i <= 10; i++) {
sum += 1.0 / i;
}
System.out.println("Sum = " + sum);
}
public static void main ()
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter numbers”);
int x,n,p;
x=sc.nextInt();
n=sc.nextInt();
p=sc.nextInt();
KboatOverloadSeries ob=new KboatOverloadSeries();
Ob. series(x,n);
Ob. series(p);
Ob. series();
}
}
VARIABLE DESCRIPTION:
CODE:
VARIABLE DESCRIPTION:
Variables Data type Description
v double For calculating the volume
r double For radius
h double For height
l double For length
b double For breadth
class : ElectricBill
Member methods:
void accept( ) — to accept the name of the customer and number of units consumed
void calculate( ) — to calculate the bill as per the following tariff:
Number of
Rate per unit
units
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
Write a main method to create an object of the class and call the above member methods.
CODE:
import java.util.Scanner;
VARIABLE DESCRIPTION:
Write a program to compute the interest according to the given conditions and display the output.
Time Rate of interest
CODE:
import java.util.Scanner;
interest = (p * r * t) / 100.0;
amt = p + interest;
}
VARIABLE DESCRIPTION:
More than Rs. 1000 and less than or equal to Rs. 3000 10% of price
More than % 3000 15% of price
(iv) void display() — To display the name and price of the book after discount. Write a main method to
create an object of the class and call the above member methods.
CODE:
import java.util.Scanner;
public BookFair() {
bname = "";
price = 0.0;
}
price -= disc;
}
VARIABLE DESCRIPTION:
Variables Data type Description
bname String For storing book name
price double For storing book price
dis double For calculating discount
net double For calculating net price
6 Write a program to accept a string and print the frequency of vowels, capitals, letters and digits in it.
CODE:
Class Str
{
void countCharacterType(String str)
{
// Declare the variable vowels, consonant, digit
// and special characters
int vowels = 0, consonant = 0, specialChar = 0,
digit = 0;
char ch = str.charAt(i);
// Driver function.
public static void main()
{
String str = "geeks for geeks121";
str ob=new str();
ob.countCharacterType(str);
}
}
VARIABLE DESCRIPTION:
7 Write a program to accept a string and print whether the string is a palindrome or not
CODE:
import java.util.*;
class PalindromeExample2
{
public static void main(String args[])
{
String original, reverse = ""; // Objects of String class
Scanner in = new Scanner(System.in);
System.out.println("Enter a string/number to check if it is a palindrome");
original = in.nextLine();
int length = original.length();
for ( int i = length - 1; i >= 0; i-- )
reverse = reverse + original.charAt(i);
if (original.equals(reverse))
System.out.println("Entered string/number is a palindrome.");
else
System.out.println("Entered string/number isn't a palindrome.");
}
}
VARIABLE DESCRIPTION:
8 Write a program to accept name and total marks of N number of students in two single subscript
arrays name[] and totalmarks[].
Calculate and print:
A. The average of the total marks obtained by N number of students. [average = (sum of
total marks of all the students)/N
B. Deviation of each student’s tortal marks with the average. [deviation=total
marks of a student-average]
CODE:
import java.util.Scanner;
VARIABLE DESCRIPTION:
9 Write a program to accept a list of n names. Sort the names in alphabetic order using Bubble Sort
Technique and print the names in sorted order in the following way. [Use compareTo()]
Serial Number Name 1 -------
2 -------
3 -------
CODE:
import java.util.*;
class GFG {
public static void main()
{
// storing input in variable
Scanner sc=new Scanner(System.in);
System.out.println(“Enter number of names”);
int n=sc.nextInt();
CODE:
import java.util.Scanner;
switch (choice) {
case 1:
int copyNum = num;
int revNum = 0;
while(copyNum != 0) {
int digit = copyNum % 10;
copyNum /= 10;
revNum = revNum * 10 + digit;
}
if (revNum == num)
System.out.println(num + " is palindrome");
else
System.out.println(num + " is not palindrome");
break;
case 2:
int result = 0;
int orig = number;
while(number != 0){
int remainder = number%10;
result = result + remainder*remainder*remainder;
number = number/10;
}
if (result == orig)
System.out.println(num + " is a Armstrong number");
else
System.out.println(num + " is not a Armstrong number");
break;
default:
System.out.println("Incorrect Choice");
break;
}
}
}
VARIABLE DESCRIPTION:
Write a main() method to create an object of the class and call the above methods.
CODE:
import java.util.Scanner;
VARIABLE DESCRIPTION:
CODE:
import java.util.Scanner;
VARIABLE DESCRIPTION:
E.g
Input : - 23487
Output: - Prime digits are : 2 3 7
Sum : 12
CODE:
import java.util.*;
int sum=0,d;
while(n!=0){
d=n%10;
System.out.print(d+" ");
sum+=d;
n/=10;
sumprime((new Scanner(System.in)).nextInt());
}
VARIABLE DESCRIPTION:
CODE:
class Overload
if(ch=='s')
num*=num;
else
num*=num*num;
if(ch=='p')
a*=b;
else
a+=b;
if(s1==s2)
System.out.println("Numbers are equal.");
else
VARIABLE DESCRIPTION:
Apply this function to find the sum of the following series in the main-function. (Note : n! = 1 x 2 x
3 x................................................x n )
S = 1 + 1 + 1 +..........................+1
2! 4! 6! 10!
CODE:
import java.util.*;
class GFG {
// Driver program
public static void main (String[] args)
{
int n = 5;
System.out.println(sum(n));
}
}
VARIABLE DESCRIPTION:
CODE:
import java.util.*;
public class str_cap
{
Scanner sc=new Scanner(System.in);
void cap()
{
System.out.println("Enter a word");
String w=sc.next();
System.out.println(w.toUpperCase());
}
void small()
{
System.out.println("Enter a word");
String w=sc.next();
System.out.println(w.toLowerCase());
}
VARIABLE DESCRIPTION:
1. void polygon(int n, char ch) — with one integer and one character type argument to draw a filled square of
side n using the character stored in ch.
2. void polygon(int x, int y) — with two integer arguments that draws a filled rectangle of length x and
breadth y, using the symbol '@'.
3. void polygon() — with no argument that draws a filled triangle shown below:
Example:
CODE:
public class KboatPolygon
{
public void polygon(int n, char ch) {
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++) {
System.out.print(ch);
}
System.out.println();
}
}
VARIABLE DESCRIPTION:
18 Write a program to accept a number and check and display whether it is a spy number or not.
(A number is spy if the sum of its digits equals the product of its digits.)
Example : consider the number 1124,
Sum of the digits = 1 + 1 + 2 + 4 = 8
Product of the digits = 1 × 1 x 2 x 4 = 8
CODE:
import java.util.Scanner;
sum += digit;
prod *= digit;
num /= 10;
}
if (sum == prod)
System.out.println(orgNum + " is Spy Number");
else
System.out.println(orgNum + " is not Spy Number");
}
}
VARIABLE DESCRIPTION:
19 Write a FUNCTION prime(int) to input a number and display the digits which are prime. Also print the
sum of the prime digits
E.g
Input : - 23489
Output: - Prime digits are : 2 3 9
CODE:
import java.util.*;
while(n!=0){
d=n%10;
System.out.print(d+" ");
n/=10;
sumprime((new Scanner(System.in)).nextInt());
}
VARIABLE DESCRIPTION:
20 Write a program in java to overload the following function findarea(). The details of the class is given below:
class : Area
member function:
void findarea(int a,int b)-to calculate the area of a rectangle
void findarea(int a)- to calculate the area of a square
void findarea(double r)- to calculate the area of a circle
CODE:
}
public static void main()
{
area ob=new area();
ob.findarea(10,12);
ob.findarea(9);
ob.findarea(5.6);
}
}
VARIABLE DESCRIPTION: