Skip to content

Commit 6353c4b

Browse files
authored
Merge pull request #51 from Priya-shan/main
Added 3 Programs - Breakdigit, ReverseArray, RandomNumberGenerator
2 parents 2418c57 + a09f97c commit 6353c4b

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

BreakDigit.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.worksheet1;
7+
8+
import java.util.Scanner;
9+
10+
/**
11+
*
12+
* @author Shanmuga Priya M
13+
*/
14+
public class breakdigit {
15+
16+
/**
17+
* @param args the command line arguments
18+
*/
19+
public static void main(String[] args) {
20+
int n,r,i,j;
21+
i=0;
22+
int a[]=new int[10];
23+
Scanner obj= new Scanner(System.in);
24+
n=obj.nextInt();
25+
while(n>0){
26+
r=n%10;
27+
a[i]=r;
28+
n=n/10;
29+
i++;
30+
}
31+
for(j=i-1;j>=0 ;j--){
32+
System.out.println(a[j]);
33+
}
34+
35+
}
36+
37+
}

RandomNumber.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.worksheet1;
7+
8+
/**
9+
*
10+
* @author Shanmuga Priya M
11+
*/
12+
public class randomno {
13+
14+
/**
15+
* @param args the command line arguments
16+
*/
17+
public static void main(String[] args) {
18+
int a= (int)((Math.random()*10));
19+
System.out.println(a);
20+
// TODO code application logic here
21+
}
22+
23+
}

ReverseArray.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package com.mycompany.worksheet1;
7+
8+
import java.util.Scanner;
9+
10+
/**
11+
*
12+
* @author Shanmuga Priya M
13+
*/
14+
public class reversearray {
15+
16+
/**
17+
* @param args the command line arguments
18+
*/
19+
public static void main(String[] args) {
20+
int a[]=new int[10];
21+
int n,i;
22+
Scanner obj= new Scanner(System.in);
23+
System.out.println("enter sizr of array");
24+
n=obj.nextInt();
25+
System.out.println("enter elements of array");
26+
for(i=0;i<n;i++){
27+
a[i]=obj.nextInt();
28+
}
29+
for(i=n-1;i>=0;i--){
30+
System.out.println(a[i]);
31+
}
32+
}
33+
34+
}

0 commit comments

Comments
 (0)