Professional Documents
Culture Documents
Comp Project
Comp Project
INDEX:
Name Page no
1. Shopkeeper 2
2. Gold 3
3. Equable Triangle 6
4. Series 8
5. Co-ordinates 10
6. Operations 11
7. Cybercafe 14
8. Physics 16
9. LG 18
10. Courier 20
11. Retirement 22
12. Electric bill 24
13. Pension 26
14. Showroom 28
15. Hotel GST 30
16. Menu 1 32
17. End 35
18. Series 2 37
19. Menu 2 39
20. LIC 42
21. Cookie 44
22. Parking 46
23. Menu3 49
24. Coprime 51
25. ATM 53
2|Page
1) Shopkeeper
import java.util.*;
class Shopkeeper
{
public static void main(String args[])
{
String name;
int license;
double income;
Scanner sc=new Scanner(System.in);
System.out.println("Enter name");
name=sc.nextLine();
System.out.println("Enter license number");
license=sc.nextInt();
System.out.println("Enter monthly income");
income=sc.nextDouble();
System.out.println("Name of the Shopkeeper is "+name);
System.out.println("License of the Shopkeeper "+name+" is "+license);
System.out.println("Income of the Shopkeeper "+name+" is "+income);
}
} Output:
3|Page
2) Gold
import java.util.*;
class Gold
double sov,kg,mg,g;
sov=sc.nextInt();
kg=sov/125;
g=kg*1000;
mg=g*1000;
System.out.println("********************************************");
System.out.println("********************************************");
System.out.println("=============================================");
}import java.util.*;
class Gold
double sov,kg,mg,g;
sov=sc.nextInt();
kg=sov/125;
g=kg*1000;
mg=g*1000;
System.out.println("********************************************");
System.out.println("********************************************");
System.out.println("=============================================");
}
5|Page
OUTPUT:
6|Page
3)Equable Triangle
import java.util.*;
class Triangle
double a,b,c;
a=sc.nextDouble();
b=sc.nextDouble();
c=sc.nextDouble();
double s=(a+b+c)/2;
double area;
area=Math.sqrt(s*(s-a)*(s-b)*(s-c));
double perimeter=a+b+c;
if(perimeter==area)
System.out.println("Triangle is equable");
else
}
7|Page
Output:
8|Page
4) Series
import java.util.*;
class Series
double a1,a2,a3;
a1=sc.nextInt();a2=sc.nextInt();a3=sc.nextInt();
double d1,d2,r1,r2;
d1=a2-a1;
d2=a3-a2;
if(d1==d2)
r1=a2/a1;r2=a3/a2;
if(r1==r2)
if(d1!=d2&&r1!=r2)
}
9|Page
OUTPUT
10 | P a g e
5) Co-ordinates
import java.util.*;
class Coordinate
double x1,x2,y1,y2;
x1=sc.nextDouble();x2=sc.nextDouble();y1=sc.nextDouble();y2=sc.nextDouble();
double AB=Math.sqrt((Math.pow(x2-x1,2))+(Math.pow(y2-y1,2)));
double m=y2-y1/x2-x1;
double X=(x1+x2)/2;
double Y=(y1+y2)/2;
}} Output:
:
11 | P a g e
6) Operations
import java.util.*;
class input
int num1,num2;
double result=0;
num1=sc.nextInt();num2=sc.nextInt();
char opr;
opr=sc.next().charAt(0);
if(opr=='+')
result=num1+num2;
if(opr=='*')
result=num1*num2;
if(opr=='-')
if(num1>num2)
result=num1-num2;
if(num2>num1)
12 | P a g e
result=num2-num1;
if(opr=='/')
if(num1>num2)
result=num1/num2;
if(num2>num1)
result=num2/num1;
if(opr!='+'&&opr!='-'&&opr!='/'&&opr!='*')
System.exit(0);
System.out.println("Result is "+result);
}
13 | P a g e
Output:
14 | P a g e
7) Cybercafe
import java.util.*;
class cybercafe
int hour,charge=0;
hour=sc.nextInt();
if(hour<=1)
charge=20;
if(hour<=5)
charge=hour*15;
if(hour>5)
charge=hour*10;
System.out.println("Charge is "+charge);
}
15 | P a g e
Output:
16 | P a g e
8) Physics
import java.util.*;
class Physics
double m,r;
m=sc.nextDouble();r=sc.nextDouble();
double G=6.673*Math.pow(10,-11);
double g=G*m/Math.pow(r,2);
int n1,n2,n3;
n1=sc.nextInt();n2=sc.nextInt();n3=sc.nextInt();
double sum=Math.cbrt(n1)+Math.cbrt(n2)+Math.cbrt(n3);
double product=Math.sqrt(n1)*Math.sqrt(n2)*Math.sqrt(n3);
int M,N;
M=sc.nextInt();
N=sc.nextInt();
double sum1;
sum1=Math.sqrt(M*N)+Math.cbrt(M+N);
System.out.println("Result is"+sum1);
17 | P a g e
Output:
18 | P a g e
9) LG
import java.util.*;
class LG
String name;
double p1,p2,p3,sum1,sum2,sum3,sum4;
name=sc.nextLine();p1=sc.nextDouble();p2=sc.nextDouble();p3=sc.nextDouble();
sum1=p1-p1*10/100;
sum2=p2-p2*12/100;
sum3=p3-p3*15/100;
sum4=sum1+sum2+sum3;
System.out.println("******************************");
System.out.println(" LG Showroom");
System.out.println("Name: "+name);
System.out.println("******************************");
}
19 | P a g e
Output:
20 | P a g e
10) Courier
import java.util.*;
class Express
char x;
int w,charge=0;
x=sc.next().charAt(0);
w=sc.nextInt();
if(x=='O')
if(w<=100)
charge=80;
if(w>100&&w<=500)
charge=150;
if(w>500&&w<=1000)
charge=210;
if(w>1000)
charge=250;
if(x=='E')
if(w<=100)
21 | P a g e
charge=100;
if(w<=500&&w>100)
charge=200;
if(w>500&&w<=1000)
charge=250;
if(w>1000)
charge=300;
if(x!='E'&&x!='O')
System.out.println("Charge is "+charge);
Output:
22 | P a g e
11) Retirement
import java.util.*;
class Retirement
String name;
int age;
double basic,ms=0;
name=sc.nextLine();basic=sc.nextDouble();age=sc.nextInt();
if(age<=40)
ms=basic*1.1/100+basic*20/100;
if(age>40&&age<=50)
ms=basic*1.25/100+basic*30/100;
if(age>50&&age<=60)
ms=basic*1.5/100+basic*40/100;
}
23 | P a g e
Output:
24 | P a g e
import java.util.*;
class ElectricBill
double units,r,sum=0;
String name;
units=sc.nextDouble();name=sc.nextLine();
if(units<=100)
r=5.0;
sum=units*r;
if(units>100&&units<=300)
sum=5*100+(units-100)*3.0;
if(units>300)
r=2.0;
sum=5*100+3*200+(units-300)*2;
sum=sum+sum*2.5/100;
Output:
26 | P a g e
13) Pension
import java.util.*;
class Pension
char g;
int age,p=0,tp;
g=sc.next().charAt(0);age=sc.nextInt();
if(g=='M')
if(age>60&&age<=70)
p=250;
if(age>70)
p=300;
if(g=='F')
if(age>58&&age<=68)
p=275;
if(age>68)
p=335;
tp=p*4;
Output:
28 | P a g e
14) Showroom
import java.util.*;
class Showroom
double sp,sum,dv,org;
int t,r=0;
sp=sc.nextDouble();t=sc.nextInt();
org=sp;
if(t==1)
r=10;
if(t==2)
r=20;
if(t==3)
r=30;
if(t==4)
r=50;
if(t>4)
r=60;
sum=sp-sp*r/100;
dv=org-sum;
}
29 | P a g e
Output:
30 | P a g e
import java.util.*;
class Hotel
double tariff,gst,Billamt;
void take_input()
tariff=0.0;
String name,cin,cout;
name=sc.nextLine();cin=sc.nextLine();cout=sc.nextLine();
tariff=sc.nextDouble();
void calcgst()
if(tariff<1000)
gst=tariff*0/100;
if(tariff>=1000&&tariff<=2499)
gst=tariff*12/100;
if(tariff>=2500&&tariff<=7499)
gst=tariff*18/100;
if(tariff>7500)
gst=tariff*28/100;
Billamt=gst;
}
31 | P a g e
void display()
System.out.println(tariff+"\t\t"+gst+"\t\t"+Billamt);
void main()
ht.take_input();
ht.calcgst();
ht.display();
Output:
32 | P a g e
16) Menu 1
import java.util.*;
class menu
int n,i,i2=0,f=0,f3;
char ch;
boolean x=true;
System.out.println("Enter P if you want to check for prime number and Enter D if you want to check
for duck number");
ch=sc.next().charAt(0);
System.out.println("Enter number");
33 | P a g e
n=sc.nextInt();
if(ch=='P')
while(true)
f=0;
for(i=1;i<=n;i++)
if(n%i==0)
f++;
if(f==2)
System.out.println(n);
break;
else
n=n+1;
if(ch=='D')
while(n!=0)
f=n%10;
n=n/10;
if(f==0)
i2=1;
34 | P a g e
break;
if(i2==1)
if(i2!=1)
if(ch!='P'&&ch!='D')
Output:
35 | P a g e
17) End
import java.util.*;
class end
int x=sc.nextInt();
int i,last,first;
boolean c=true;
if(x>=10)
last=x%10;
i=x-last;
while(i>=10)
i=i/10;
if(i==last)
else
else
}
37 | P a g e
18) Series2
import java.util.*;
class Series2
int a1,a2,a3;
double d1,d2,r1,r2;
a1=sc.nextInt();a2=sc.nextInt();a3=sc.nextInt();
d1=a2-a1;
d2=a3-a2;
if(d1==d2)
r1=a2/a1;
r2=a3/a2;
if(r1==r2)
}
38 | P a g e
Output:
39 | P a g e
19) Menu2
import java.util.*;
class DSLI {
char choice;
choice = sc.next().charAt(0);
switch(choice) {
case 'D':
case 'd':
System.out.println("Enter number");
int x = sc.nextInt();
org = x;
while (x != 0) {
x = x / 10;
c++;
while (org != 0) {
r = org % 10;
}
40 | P a g e
System.out.println(sum);
break;
case 'S':
case 's':
int s = 99, i;
System.out.println(s);
s = s - i;
System.out.println(s);
break;
case 'L':
case 'l':
int n = sc.nextInt();
} else {
break;
default:
System.out.println("Invalid choice");
}
41 | P a g e
Output:
42 | P a g e
20) LIC
import java.util.*;
class LIC {
String name;
name = sc.nextLine();
sum = sc.nextDouble();
premium=sum-(sum*discount)-(sum*commission);
commission2=(sum*commission);
System.out.println("Premium :"+premium);
Output:
44 | P a g e
21) Cookie
import java.util.*;
class cookie
int cookie,box,n,tot_box,container;
void enter()
cookie=sc.nextInt();
box=sc.nextInt();
n=sc.nextInt();
void Do()
tot_box=cookie/box;
container=tot_box/n;
System.out.println(tot_box);
void view()
System.out.println("================================================");
System.out.println("================================================");
Output:
46 | P a g e
22) Parking
import java.util.*;
class Parking
String name,vno;
long mno;
int hrs,charge,org;
String vehichle;
void input()
System.out.println("Enter your name and the vehichle's number and the name of the vehichle");
name=sc.nextLine();
vno=sc.nextLine();
vehichle=sc.nextLine();
System.out.println("Enter your mobile number and the number of hours the bike was rented");
mno=sc.nextLong();
hrs=sc.nextInt();
void compute()
org=hrs-5;
hrs=hrs;
if(org<=5)
{
47 | P a g e
charge=hrs*10;
if(org>5&&org<=10)
charge=5*10+org*5;
if(org>10)
charge=5*10+5*5+(org-5)*3;
void display()
System.out.println("Charge is "+charge);
Output:
48 | P a g e
49 | P a g e
23) Menu3
import java.util.*;
class menu2 {
String choice;
System.out.println("Enter sd for checking smallest digit and comp for checking composite");
choice = sc.nextLine();
System.out.println("Enter number");
int n = sc.nextInt();
if (choice.equals("sd"))
int r = 0, sd = n % 10;
while (n != 0) {
r = n % 10;
n = n / 10;
if (r < sd) {
sd = r;
if (choice.equals("comp"))
int c = 0;
50 | P a g e
if (n % i == 0) {
c++;
break;
if (c > 0) {
System.out.println("Number is composite");
} else {
Output:
51 | P a g e
24) Co-Prime
import java.util.*;
class coprime
int x,y,hcf=0,i;
x=sc.nextInt();y=sc.nextInt();
for(i=1;i<=x;i++)
if(x%i==0&&y%i==0)
hcf++;
if(hcf==1)
if(hcf!=1)
}
52 | P a g e
Output:
53 | P a g e
25) ATM
import java.util.*;
class ATM
int bal,ch,amount;
boolean a=true;
System.out.println("Enter balance");
bal=sc.nextInt();
while(true)
ch=sc.nextInt();
if(ch==1)
amount=sc.nextInt();
bal=bal+amount;
if(ch==2)
amount=sc.nextInt();
bal=bal-amount;
54 | P a g e
if(ch==3)
System.out.println("Balance is "+bal);
if(ch==4)
System.exit(0);
Output: