Comp Appl Project
Comp Appl Project
Computer
Applications Project
1st term
class product_of_last_digits
a=sc.nextInt();
c=sc.nextInt();
x=a%10;
z=c%10;
System.out.println("The product of the last three digits of the given numbers is:-"+p);
Output of program 1
Program 2
2> Write a program to input the principal, rate of interest and time in year. Find out simple
interest and amount.
class simple_interest
p=sc.nextDouble();
t=sc.nextDouble();
Output of program 2
Program 3
3> Write a program to accept the temperature in Celsius and convert this temperature into
Fahrenheit.
Ans> import java.util.Scanner;
class temperature_conversion
f=(c*(9.0/5.0))+32;
Program 4
4> Write a program in java to accept side of a square and find out its area and perimeter.
class area_perimeter
double l,a,p;
l=sc.nextDouble();
a=l*l;
p=l*4;
Output of program 4
Program 5
5> Write a program to input time in seconds and display the time broken up as hours,
minutes and
seconds.
class time_conversion
seconds=sc.nextLong();
hrs=seconds/3600;
mins=seconds/60;
Output of program 5
Program 6
6>Write a program to input three integers and find the sum of the cube roots of their last
digits.
class playing_with_numbers
double x,y,z,sum;
a=sc.nextLong();
c=sc.nextLong();
a=a%10;
c=c%10;
x=Math.cbrt(a);
z=Math.cbrt(c);
}
Method name Variable Name Data Type Uses
sc Scanner Object to accept
input from user
To accept 1st integer
integers() a long number from user
And also to store last
digit
b long To accept 2nd integer
number from user
And also to store last
digit
c long To accept 3rd integer
number from user
And also to store last
digit
x double To find cube root
from the 1st integer’s
last digit
y double To find cube root
from the 2nd integer’s
last digit
z double To find cube root
from the 3rd integer’s
last digit
sum double To store the sum of x,
y and z
Output of program 6
Program 7
7> Write a program in java to enter three unequal numbers and display the largest among
them.
class numbers
a=sc.nextInt();
c=sc.nextInt();
if(a>b&&a>c)
else if(b>a&&b>c)
else
}
Method Name Variable Name Data Type Uses
sc Scanner Object to accept
numbers() input from user
a int To accept any integer
number from user
b int To accept any integer
number from user
c int To accept any integer
number from user
Output of program 7
Program 8
8> Write a program to accept an integer type number and check whether it is a 3-digit
number as well as divisible by seven or not.
class numbers_part2
a=sc.nextInt();
b=a%7;//storing the remainder as 0 if divivsible by 7
if(a>=99&&a<=999&&b==0)
else
Program 9
9> A travel company wants to give discount to their customer in the following way.
Ticket price % of discount on ticket price
< 3000 5
> =3001 to 10000 8
> =10001 to 25000 10
Above 25000 20
An addition travel tax of 5% of discounted amount will be added and final amount will be
calculated.
Write a program which will accept the ticket price and calculate the final amount.
class ticket_price
double price;
price=sc.nextDouble();
if(price<=3000)
price=price-((5.0/100.0)*price);
price=price+((5.0/100.0)*price);
else if(price>=3001&&price<=10000)
price=price-((8.0/100.0)*price);
price=price+((5.0/100.0)*price);
else if(price>=10001&&price<=25000)
price=price-((10.0/100.0)*price);
price=price+((5.0/100.0)*price);
else if(price>25000)
price=price-((10.0/100.0)*price);
price=price+((5.0/100.0)*price);
Output of program 9
Program 10
10> A library charges a fine for books returned late. Following are the fines:
First five days : 30 paise per day.
Next 5 days : 60 paise per day.
Above ten days: 80 paise per day.
Design a program to calculate the fine assuming that a book is returned N days late.
class library_fine
double N;
N=sc.nextDouble();
if(N==5)
{
if(N>5&&N<=10)
if(N>10)