Skip to content

Commit 59636b9

Browse files
committed
Some Changes
1 parent a8ff5f1 commit 59636b9

16 files changed

+213
-5
lines changed

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
22
"java.project.sourcePaths": [
33
"switch_case",
4+
"if-else",
45
"for_loop",
5-
"if-else"
6+
"ClassPrograms"
67
],
78
"java.project.outputPath": "bin",
89
"java.project.referencedLibraries": [

for_loop/ArrayONe.java

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.util.Scanner;
2+
3+
public class ArrayONe {
4+
public static void main(String[] args) {
5+
Scanner x = new Scanner(System.in);
6+
int arr[] = new int[10];
7+
for(int i = 0; i<10; i++)
8+
{
9+
arr[i] = x.nextInt();
10+
}
11+
for(int i = 0; i < 10;i++)
12+
{
13+
for(int j = 0; j<10-i-1; j++)
14+
{
15+
if(arr[j+1]>arr[j])
16+
{
17+
int t = arr[j];
18+
arr[j] = arr[j+1];
19+
arr[j+1] = t;
20+
}
21+
}
22+
}
23+
for(int i = 0; i<10; i++)
24+
{
25+
System.out.print(arr[i] + " ");
26+
}
27+
28+
}
29+
}

for_loop/City.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.Scanner;
2+
class City
3+
{
4+
public static void main(String[] args) {
5+
Scanner x = new Scanner(System.in);
6+
String a[] = new String[5];
7+
for(int i = 0; i<5; i++)
8+
{
9+
a[i] = x.nextLine();
10+
}
11+
for(int i=0; i<4; i++)
12+
{
13+
if(a[i+1].length() < a[i].length()){
14+
String temp = a[i];
15+
a[i] = a[i+1];
16+
a[i+1] = temp;
17+
}
18+
19+
}
20+
for(int i = 0; i<5; i++)
21+
{
22+
System.out.println(a[i]);
23+
}
24+
}
25+
}

for_loop/ClassTEacher.java

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
public class ClassTEacher {
2+
public static void main(String[] args) {
3+
int DDA[][] = new int[40][5];
4+
5+
}
6+
}

for_loop/FruitJOOOSE.java

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import java.util.Scanner;
2+
public class FruitJOOOSE
3+
{
4+
int product_code, pack_size, product_price;
5+
String flavous, pack_type;
6+
FruitJOOOSE()
7+
{
8+
product_code = 0;
9+
product_price = 0;
10+
pack_size = 0;
11+
flavous = "";
12+
pack_type = "";
13+
}
14+
void input()
15+
{
16+
Scanner x = new Scanner(System.in);
17+
System.out.println("Enter flavour");
18+
flavous = x.nextLine();
19+
System.out.println("pack type");
20+
pack_type = x.nextLine();
21+
System.out.println("Enter Product Code");
22+
product_code = x.nextInt();
23+
System.out.println("pack size");
24+
pack_size = x.nextInt();
25+
System.out.println("Production price");
26+
product_price = x.nextInt();
27+
x.close();
28+
}
29+
void discount()
30+
{
31+
product_price -=10;
32+
}
33+
void display()
34+
{
35+
System.out.println("Product Code: "+product_code);
36+
System.out.println("Flavour: "+flavous);
37+
System.out.println("Pack type: "+pack_type);
38+
System.out.println("Pack Size: "+pack_size);
39+
System.out.println("Product Cost: "+product_price);
40+
}
41+
public static void main(String[] args) {
42+
FruitJOOOSE ob = new FruitJOOOSE();
43+
ob.input();
44+
ob.discount();
45+
ob.display();
46+
}
47+
}

for_loop/HappyWord.java

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import java.util.Scanner;
2+
3+
public class HappyWord {
4+
public static void main(String[] args) {
5+
Scanner x = new Scanner(System.in);
6+
String word;
7+
System.out.println("Enter word");
8+
word = x.next();
9+
10+
}
11+
}

for_loop/ISBN.java

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import java.util.Scanner;
2+
3+
public class ISBN {
4+
public static void main(String[] args) {
5+
Scanner x = new Scanner(System.in);
6+
long ISBN;
7+
System.out.println("Enter ISBN");
8+
ISBN = x.nextLong();
9+
long c = ISBN;
10+
int i=0;
11+
while (c!=0)
12+
{
13+
c/=10;
14+
i++;
15+
}
16+
c = ISBN;
17+
18+
if(i==10)
19+
{
20+
int a=0;
21+
long d;
22+
while(c!=0)
23+
{
24+
d = c%10;
25+
for(i = 10; i>=1; i--)
26+
{
27+
a+=i*(int)d;
28+
//System.out.print(a+" ");
29+
}
30+
c/=10;
31+
}
32+
if(a%11==0)
33+
{
34+
System.out.println("Legal ISBN");
35+
}
36+
else{
37+
System.out.print("Illegal ISBN");
38+
}
39+
}
40+
else{
41+
System.out.println("Illegal ISBN");
42+
}
43+
x.close();
44+
}
45+
}

for_loop/Matrix_Calculate.java

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
public class Matrix_Calculate {
2+
public static void main(String[] args) {
3+
int M[][] = {{-1,0,2},{-3,-1,6},{4,3,-1}};
4+
int S[][] = {{-6,9,4},{4,5,0},{1,-2,-3}};
5+
int N[][] = new int[3][3];
6+
7+
for(int i = 0; i<3; i++)
8+
{
9+
for(int j = 0 ; j<3; j++)
10+
{
11+
N[i][j] = S[i][j] - M[i][j];
12+
}
13+
}
14+
for(int i = 0; i<3; i++)
15+
{
16+
for(int j = 0 ; j<3; j++)
17+
{
18+
System.out.print(N[i][j]+" ");
19+
}
20+
System.out.println();
21+
}
22+
}
23+
}

for_loop/PRODDIGI.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public static void main(String[] args) {
88
System.out.println("Enter a num");
99

1010
n = x.nextInt();
11-
11+
x.close();
1212
while(n>0)
1313
{
1414
d = n%10;

for_loop/Piglatin.java

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java.util.Scanner;
2+
3+
public class Piglatin {
4+
public static void main(String[] args) {
5+
Scanner x = new Scanner(System.in);
6+
String word;
7+
System.out.println("Enter the word");
8+
word = x.nextLine();
9+
word = word.toUpperCase();
10+
int c=word.indexOf('O');
11+
word = word.substring(c)+word.substring(0,c)+"AY";
12+
System.out.print(word);
13+
14+
}
15+
}

for_loop/Project_program3.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ public static void main(String[] args) {
66
int i,n,f=0;
77
System.out.println("Enter a numer to check whether its prime or composites");
88
n = x.nextInt();
9+
x.close();
910

1011
for (i=2;i<=n/2;i++) if (n%i==0) f+=1;
1112
if (f==0) System.out.println("Prime");
1213
else System.out.println("Composite");
13-
x.close();
14+
1415
}
1516
}

for_loop/Project_program5.java

+2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ public static void main(String args[]){
77
a = sc.nextInt();
88
System.out.println("Enter second number :: ");
99
b = sc.nextInt();
10+
sc.close();
1011

1112
for(i = 1; i <= a || i <= b; i++) {
1213
if( a%i == 0 && b%i == 0 )
1314
hcf = i;
1415
}
1516
System.out.println("HCF of given two numbers is ::"+hcf);
17+
1618
}
1719
}

for_loop/Project_program6.java

+1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ public static void main(String[] args) {
3535
break;
3636
default:System.out.println("Incorect choice");
3737
}
38+
sc.close();
3839
}
3940
}

for_loop/REV.java

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ public static void main(String[] args) {
1616
n=n/10;
1717
}
1818
System.out.println(r);
19+
x.close();
1920
}
2021
}

for_loop/SUMDIGI.java

+1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ public static void main(String[] args) {
1616
n=n/10;
1717
}
1818
System.out.println(s);
19+
x.close();
1920
}
2021
}

for_loop/duck.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
public class duck {
44
public static void main(String[] args) {
55
Scanner x = new Scanner(System.in);
6-
int n,d,s=0,f=0;
7-
6+
int n,d,f=0;
7+
x.close();
88
System.out.println("Enter a num");
99

1010
n = x.nextInt();

0 commit comments

Comments
 (0)