Record Work Computer Applications Class 10 Term 1: By: 05 Akshara Senthil 10B Sishya OMR School
Record Work Computer Applications Class 10 Term 1: By: 05 Akshara Senthil 10B Sishya OMR School
Index
Serial No. Content Page No.
1 Index 1
2 Record 1 2&3
3 Record 2 4&5
4 Record 3 6&7
5 Record 4 8&9
6 Record 5 10-12
7 Record 6 13-15
8 Record 7 16 & 17
9 Record 8 18 & 19
10 Record 9 20 & 21
11 Record 10 22 & 23
12 Record 11 24-26
13 Record 12 27-29
14 Record 13 30 & 31
Record 1
Aim
Write a program to calculate the special discount in a laptop shop with the following
specifications:
Class name: laptop
Instance variables: name, price, dis, amt
Methods:
1. Accept details of the customer
2. To compute discount as per the following table:
upto 25,000 5%
25001-50000 7.5%
50001-100000 10%
>100000 15%
3. Display name, dis, and amt
Source Code
import java.util.*;
public class laptop
{
String name;
double price,dis,amt;
public static void main(String args[])
{
laptop object=new laptop();
object.accept();
object.calculate();
object.display();
}
void accept()
{
Scanner obj = new Scanner(System.in);
System.out.println("Enter your name: ");
name=obj.nextLine();
System.out.println("Enter price: ");
price=obj.nextInt();
}
void calculate()
{
if(price<=25000)
{
dis=(5.0/100.0)*price;
amt=price-dis;
}
else if(price>=25001&&price<=50000)
{
dis=(7.5/100.0)*price;
amt=price-dis;
}
else if(price>=50001&&price<=100000)
{
dis=(10.0/100.0)*price;
amt=price-dis;
}
else
{
dis=(15.0/100.0)*price;
amt=price-dis;
}
}
void display()
{
System.out.println("Name of customer: " + name);
System.out.println("Discount on price: " + dis);
System.out.println("Amount with discount: " + amt);
}
}
Input/Output
Record 2
Aim
Write a program to accept a number and check whether it is a spy number or not.
Spy number:- A number whose sum of the digits equals the product of the digits.
Source Code
import java.util.*;
public class record2tenthgrade
{
public static void main(String args[])
{
int n,s=0,p=1,rem=0;
System.out.println("Enter a number to check whether it is a spy number or not: ");
Scanner obj = new Scanner(System.in);
n=obj.nextInt();
while(n!=0)
{
rem=n%10;
n=n/10;
s=s+rem;
p=p*rem;
}
if(s==p)
System.out.println("Spy number");
else
System.out.println("Not a spy number");
}
}
Variable Description Table
Name Data Type Description
n int To accept the number to be
checked
s int To calculate and store the
sum of the digits of the
number
p int To calculate and store the
product of the digits of the
number
rem int To help in calculating the
sum and product of the
digits
Input/Output
Record 3
Aim
Given below is a hypothetical table showing the rate of income tax for a male citizen of an
age below 65 years:
Taxable income Income tax
does not exceed 2,50,000 nil
more than 2,50,000 but less than or equal (TI-2,50,000)*10%
to 5,00,000
greater than 5,00,000 but less than or equal ((TI-5,00,000)*20%)+34,000
to 10,00,000
more than 10,00,000 ((TI-10,00,000)*30%)+94000
Write a program to input the age, gender, taxable income of a person. If the age of a person
is above 65 years or they are of the female gender, display 'Wrong Category'. If the age is
less than or equal to 65 years and gender is male, compute and display the income tax to be
paid.
Source Code
import java.util.*;
public class record3tenthgrade
{
public static void main(String args[])
{
double age,ti,am=0;
char gender;
Scanner obj = new Scanner(System.in);
System.out.println("Input your age and taxable income");
age=obj.nextDouble();
ti=obj.nextDouble();
System.out.println("Enter 'M' for male and 'F' for female");
gender=obj.next().charAt(0);
if(age<65&&gender=='M')
{
if(ti<=250000.0)
{
am=0;
}
else if(ti>250000.0&&ti<=500000.0)
{
am=(ti-250000.0)*(10.0/100.0);
}
else if(ti>500000.0&&ti<+1000000.0)
{
am=((ti-500000.0)*(20.0/100.0))+34000.0;
}
else if(ti>1000000.0)
{
am=((ti-1000000.0)*(30.0/100.0))+94000.0;
}
}
else if(age>=65||gender=='F')
{
System.out.println("Wrong category");
}
System.out.println("Total amount is: " + am);
}
}
Variable Description Table
Name Data Type Description
age double To accept the age of the
taxpayer
ti double To accept the taxable
income of the taxpayer
am double To calculate, store, and
display the total amount of
income tax to be paid by the
taxpayer
gender char To accept the gender of the
taxpayer
Input/Output
Record 4
Aim
Write a program to enter two numbers and check whether they are co-prime or not.
Co-prime numbers:- They are numbers whose only common factor is one.
Source Code
import java.util.*;
public class record4tenthgrade
{
public static void main(String args[])
{
int a,b,j=0;
Scanner obj = new Scanner(System.in);
System.out.println("Enter two numbers to check if they are co-prime or not: ");
a=obj.nextInt();
b=obj.nextInt();
for(int i=1;i<=a||i<=b;i++)
{
if(a%i==0&&b%i==0)
++j;
else
continue;
}
if(j==1)
System.out.println("They are co-prime");
else
System.out.println("They are not co-prime");
}
}
Source Code
import java.util.*;
public class record5tenthgrade
{
public static void main(String args[])
{
double n,s=0,s2=1,b=1,c=0;
int a,choice,exp=1;
Scanner obj = new Scanner(System.in);
System.out.println("Input till which term you want the series to go on");
n=obj.nextDouble();
System.out.println("Enter the value of a for the first case");
a=obj.nextInt();
System.out.println("Enter 1 for series 1 and 2 for series 2");
choice=obj.nextInt();
switch(choice)
{
case 1:
{
for(int i=1;i<=n;i++)
{
if(i%2==0)
{
s=s-Math.pow(a,exp);
}
else
{
s=s+Math.pow(a,exp);
}
exp=exp+2;
}
System.out.println("The sum of the series is: " + s);
break;
}
case 2:
{
for(int k=2;k<=n;k++)
{
b=1;
c=0;
for(int j=1;j<=k;j++)
{
b=b*j;
c=c+j;
}
s2=s2+(b/c);
}
System.out.println("The sum of the series is: " + s2);
break;
}
default:
System.out.println("Wrong input");
}
}
}
Data members:
int prv, pre: To accept the previous and present meter readings
int call: To store the calls made (pre-prv)
String name: To store the name of the consumer
double amt: To store the amount
double total: To store the total amount to be paid
Member functions:
void input(): Stores the previous reading, present reading, and name of the consumers
void call(): Calculates the amount and the total amount to be paid
void display(): Displays the name of the consumer, calls made, and the total amount to be
paid
Write a program to compute the monthly bill to be paid according to the given instructions:
Calls made Rate
Up to 100 calls Nill
For the next 100 calls 2 rupees per call
For the next 200 calls 3 rupees per call
More than 400 calls 4 rupees per call
However, every consumer must pay 180 rupees per month as monthly rent for the service.
Source Code
import java.util.*;
public class Telephone
{
int call,prv,pre;
String name;
double amt=0,total=0;
public static void main(String args[])
{
Telephone object=new Telephone();
object.input();
object.call();
object.display();
}
void input()
{
Scanner obj = new Scanner(System.in);
System.out.println("Input the previous meter reading: ");
prv=obj.nextInt();
System.out.println("Input the present meter reading: ");
pre=obj.nextInt();
obj.nextLine();
System.out.println("Input your name: ");
name=obj.nextLine();
}
void call()
{
call=pre-prv;
if(call<=100)
{
amt=0;
}
else if(call>100&&call<=200)
{
amt=(double)(call-100.0)*2.0+(100.0*0);
}
else if(call>200&&call<=400)
{
amt=(double)(call-200.0)*3.0+(100.0*2.0)+(100.0*0);
}
else if(call>400)
{
amt=(double)(call-400.0)*4.0+(200.0*3.0)+(100.0*2.0)+(100.0*0);
}
total=amt+180.0;
}
void display()
{
System.out.println("Name of the consumer\tCalls made\tAmount");
System.out.print(name+"\t\t\t"+call+"\t\t"+total);
}
}
Variable Description Table
Name Data Type Description
call int To store the number of calls
prv int To store previous meter
reading
pre int To store present meter
reading
name String To store the name of the
consumer
amt double To store the amount of
money to be paid by
consumer
total double To store the amount of
money to be paid by the
consumer including the
monthly service rent
Input/Output
Record 7
Aim
Write a program to accept 10 different numbers in Single-Dimensional Array and enter a
searching element and display whether the number is present or not using a linear search.
Display whether the number is present or not and display the location of the element.
Source Code
import java.util.*;
public class record7tenthgrade
{
public static void main(String args[])
{
Scanner obj = new Scanner(System.in);
System.out.println("Enter the number to find");
int choice=obj.nextInt();
int a[]=new int[10];
for(int i=0;i<10;i++)
{
System.out.println("Enter: " + (i+1) + " number");
a[i]=obj.nextInt();
}
for(int j=0;j<10;j++)
{
if(choice==a[j])
{
System.out.println("The number is present at: " + (j+1) + " location");
break;
}
if(j==9)
System.out.println("The number is not present");
}
}
}
Variable Description Table
Variable Data Type Description
choice int To input the number to
check if it is an element of
the array
i int To be the control variable of
the first loop and to input
the members of the array
j int To be the control variable of
the second variable and to
check whether the given
element is a part of the
array or not
Input/Output
Record 8
Aim
Write a program to accept 10 different numbers in a Single-Dimensional Array and enter a
searching element and display whether the number is present or not using binary search.
Source Code
import java.util.*;
public class record8tenthgrade
{
public static void main(String args[])
{
Scanner obj = new Scanner(System.in);
System.out.println("Enter the number to find: ");
int search=obj.nextInt();
int a[]=new int[10];
int lb=0,ub=9;
for(int i=0;i<10;i++)
{
System.out.println("Enter the: " + (i+1) + " number. A request to the user to enter the
number in a sorted array arranged ascendingly.");
a[i]=obj.nextInt();
}
while(lb<=ub)
{
int mid=(lb+ub)/2;
if(a[mid]==search)
{
System.out.println("The number is present at the : " + (mid+1) + " location");
break;
}
else if (a[mid]>search)
{
ub=mid-1;
}
else if(a[mid]<search)
{
lb=mid+1;
}
}
if(lb>ub)
System.out.println("The number is not found");
}
}
Variable Description Type
Variable Data Type Description
search int To input the search element
lb int To store the lower limit of
the array for calculations
ub int To store the upper limit of
the array for calculations
i int To be the control variable of
the first loop and to input
the elements of the array
mid int To store the middle value of
the loop
Input/Output
Record 9
Aim
Write a program to accept an array of numbers from a user in any order and arrange and
print the numbers in ascending order using Bubble Sort.
Source Code
import java.util.*;
public class record9tenthgrade
{
public static void main(String args[])
{
int temp=0;
Scanner obj = new Scanner(System.in);
int a[]=new int[10];
for(int k=0;k<10;k++)
{
System.out.println("Enter the " + (k+1) + " number.");
a[k]=obj.nextInt();
}
for(int i=0;i<10;i++)
{
for(int j=0;j<9;j++)
{
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
else
continue;
}
}
System.out.println("The series in ascending order is as follows: ");
for(int l=0;l<10;l++)
{
System.out.println("The " + (l+1) + " term is: " + a[l]);
}
}
}
Variable Description Table
Name Data Type Description
temp int To store the value of a
variable in the array
temporarily to switch places
with another variable in the
array
k int To be the control variable of
the loop that inputs the
array values
i int To be the control variable of
the outer loop that sorts the
array values
j int To be the control variable of
the inner loop that sorts the
array values
l int To be the control variable of
the loop that displays the
arranged array values in
ascending order
Input/Output
Record 10
Aim
Write a program to accept an array of numbers from a user in any order and arrange and
print the numbers in ascending order using Selection Sort.
Source Code
import java.util.*;
public class record10tenthgrade
{
public static void main(String args[])
{
int temp;
Scanner obj = new Scanner(System.in);
int a[]=new int[10];
for(int k=0;k<10;k++)
{
System.out.println("Enter the: " + (k+1) + " number.");
a[k]=obj.nextInt();
}
for(int i=0;i<10;i++)
{
int x=i;
for(int j=i+1;j<10;j++)
{
if(a[j]<a[x])
{
x=j;
}
}
temp=a[i];
a[i]=a[x];
a[x]=temp;
}
System.out.println("The series in ascending order is as follows: ");
for(int l=0;l<10;l++)
{
System.out.println("The " + (l+1) + " term is: " + a[l]);
}
}
}
Variable Description Table
Name Data Type Description
temp int To store the value of a
variable in the array
temporarily to switch places
with another variable in the
array
k int To be the control variable of
the loop that inputs the
array values
i int To be the control variable of
the outer loop that sorts the
array values
x int To help in the arranging of
variables by finding which
variable of the array is least,
second least, and so on
j int To be the control variable of
the inner loop that sorts the
array values
l int To be the control variable of
the loop that displays the
arranged array values in
ascending order
Input/Output
Record 11
Aim
Write a program to accept the names and total marks of 'N' number of students in two
single subscript arrays, which are name[] and totalmarks[]. Calculate and print using
methods:
1. The average of the total marks obtained by 'N' number of students, that is
Average = Sum of marks/'N' number of students
2. The deviation of each student's total marks from the average, that is
Deviation = Total marks scored by each student - average of all students' marks
Source Code
import java.util.*;
public class record11tenthgrade
{
int avg,N;
String name[];
int totalmarks[];
public static void main(String args[])
{
record11tenthgrade object = new record11tenthgrade();
object.input();
object.average();
object.deviation();
}
void input()
{
Scanner obj = new Scanner(System.in);
System.out.println("Enter the number of students: ");
N=obj.nextInt();
obj.nextLine();
name=new String[N];
totalmarks=new int[N];
for(int i=0;i<N;i++)
{
System.out.println("Enter the: " + (i+1) + " students' name.");
name[i]=obj.nextLine();
System.out.println("Enter the: " + (i+1) + " students' marks.");
totalmarks[i]=obj.nextInt();
obj.nextLine();
}
}
void average()
{
int s=0;
for(int k=0;k<N;k++)
{
s=s+totalmarks[k];
}
avg=s/N;
System.out.println("The total average is: " + avg);
}
void deviation()
{
int dev;
for(int l=0;l<N;l++)
{
dev=totalmarks[l]-avg;
System.out.println("Deviation of: " + name[l] + " students' marks is: " + dev);
}
}
}
Source Code
import java.util.*;
public class courier
{
String name, address;
double weight, bill;
char type;
public static void main(String args[])
{
courier object = new courier();
object.accept();
object.calculate();
object.print();
}
void accept()
{
Scanner obj = new Scanner(System.in);
System.out.println("Enter customer name: ");
name=obj.nextLine();
System.out.println("Enter customer address: ");
address=obj.nextLine();
System.out.println("Enter courier weight: ");
weight=obj.nextDouble();
System.out.println("Enter 'D' for domestic courier and 'I' for international courier");
type=obj.next().charAt(0);
}
void calculate()
{
if(type=='D')
{
if(weight<=5.0)
{
bill=800.0*weight;
}
else if(weight>5.0&&weight<=10.0)
{
bill=(weight-5.0)*700.0+(5.0*800.0);
}
else if(weight>10.0)
{
bill=(weight-10.0)*500+(5.0*700)+(5.0*800);
}
}
else if(type=='I')
{
if(weight<=5.0)
{
bill=(800.0*weight)+1500.0;
}
else if(weight>5.0&&weight<=10.0)
{
bill=((weight-5.0)*700.0+(5.0*800.0))+1500.0;
}
else if(weight>10.0)
{
bill=((weight-10.0)*500+(5.0*700)+(5.0*800))+1500.0;
}
}
else
{
System.out.println("Wrong input");
}
}
void print()
{
System.out.println("The name of customer is: " + name);
System.out.println("The address of customer is: " + address);
System.out.println("The weight of the courier is: " + weight);
if(type=='D')
System.out.println("The type is domestic");
else if(type=='I')
System.out.println("The type is international");
System.out.println("The final bill of the courier is: " + bill);
}
}
Input/Output
Record 13
Aim
Write a program to store six elements in an array P[] and four elements in an array Q[] to
produce a third array R[] containing all the elements of P and Q.
Source Code
import java.util.*;
public class record13tenthgrade
{
public static void main(String args[])
{
Scanner obj = new Scanner(System.in);
int P[]=new int[6];
int Q[]=new int [4];
int R[]=new int[10];
for(int i=0;i<6;i++)
{
System.out.println("Enter the: " + (i+1) + " term of the first array");
P[i]=obj.nextInt();
}
for(int j=0;j<4;j++)
{
System.out.println("Enter the: " + (j+1) + " term of the second array");
Q[j]=obj.nextInt();
}
for(int k=0;k<6;k++)
{
R[k]=P[k];
}
for(int l=0;l<4;l++)
{
R[l+6]=Q[l];
}
for(int m=0;m<10;m++)
{
System.out.println("The " + (m+1) + " term of the newly produced array is: " + R[m]);
}
}
}
Variable Description Table
Input/Output