File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ Q2.4 given number Armstrong or not ?
3+ */
4+ package nazimacadviw ;
5+
6+ import java .util .Scanner ;
7+
8+ /**
9+ *
10+ * @author Nazim
11+ */
12+ public class armstrongOrNot {
13+ public static void main (String []args ){
14+ Scanner sc =new Scanner (System .in );
15+ int num ,armstrong =0 ,r ;
16+ System .out .println ("Enter number find Armstrong or Not:" );
17+ num =sc .nextInt ();
18+ int temp =num ;
19+ int a =num %10 ;
20+ while (num >0 )
21+ {
22+ r =num % 10 ;
23+ armstrong =(int ) (armstrong + Math .pow (r , a ));
24+ num =num /10 ;
25+ }
26+ if (temp ==armstrong )
27+ System .out .println ("Number is armstrong" );
28+ else
29+ System .out .println ("Number Not Armstrong" );
30+
31+ }
32+
33+ }
34+
Original file line number Diff line number Diff line change 1+ /*
2+ Q2.2 take the number N from the user as input and find all even Numbers upto N?
3+ */
4+ package nazimacadviw ;
5+ import java .util .*;
6+
7+ /**
8+ *
9+ * @author Nazim
10+ */
11+ public class evenNumber2 {
12+ public static void main (String []arg ){
13+ Scanner sc =new Scanner (System .in );
14+ int num ;
15+ System .out .println ("Enter Number Find all even Number:" );
16+ num =sc .nextInt ();
17+ for (int i =0 ;i <=num ;i ++){
18+ if (i %2 ==0 )
19+ System .out .print (i +" " );
20+
21+ }
22+
23+
24+ }
25+
26+
27+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Q2.3 Take a Number N from the user as input and find all prime numbers upto N?
3+ */
4+ package nazimacadviw ;
5+
6+ import java .util .Scanner ;
7+
8+ /**
9+ *
10+ * @author Nazim
11+ */
12+ public class findAllPrimeNumer2
13+ {
14+ public static void main (String [] args )
15+ {
16+ Scanner scanner = new Scanner (System .in );
17+ int i =0 ;
18+ int num =0 ;
19+ //Empty String
20+ String primeNumbers = "" ;
21+ System .out .println ("Enter the value of n:" );
22+ int n = scanner .nextInt ();
23+ // scanner.close();
24+ for (i = 1 ; i <= n ; i ++)
25+ {
26+ int counter =0 ;
27+ for (num =i ; num >=1 ; num --)
28+ {
29+ if (i %num ==0 )
30+ {
31+ counter = counter + 1 ;
32+ }
33+ }
34+ if (counter ==2 )
35+ {
36+ //Appended the Prime number to the String
37+ primeNumbers = primeNumbers + i + " " ;
38+ }
39+ }
40+ System .out .println ("Prime numbers from 1 to" + n +"are :" );
41+ System .out .println (primeNumbers );
42+ }
43+
44+ }
Original file line number Diff line number Diff line change 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 nazimacadviw ;
7+ import java .util .*;
8+
9+ /**
10+ *
11+ * @author Nazim
12+ */
13+ public class gretest3Number {
14+ public static void main (String []args ){
15+ Scanner sc =new Scanner (System .in );
16+ int a ,b ,c ;
17+ System .out .println ("Enter three Number for Find Biggest Number:" );
18+ a =sc .nextInt ();
19+ b =sc .nextInt ();
20+ c =sc .nextInt ();
21+ if (a >b )
22+ {
23+ if (a >c )
24+ System .out .println ("Number is grater:" +a );
25+ else
26+ if (b >c )
27+ System .out .println ("Number is grater:" +b );
28+ else
29+ System .out .println ("Number is grater:" +c );
30+ }
31+ else
32+ {
33+ if (b >c )
34+ System .out .println ("Number is grater:" +b );
35+ else
36+ System .out .println ("Number is grater:" +c );
37+ }
38+
39+
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Q1. write a program in java that prints "Hello World" to the Screen.
3+ */
4+ package nazimacadviw ;
5+ public class helloWorld {
6+
7+
8+ public static void main (String [] args ) {
9+ System .out .println ("Hello World" );
10+ }
11+
12+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Q5.write a program given number Leap Year or not.
3+ */
4+ package nazimacadviw ;
5+ import java .util .Scanner ;
6+ /**
7+ *
8+ * @author Nazim
9+ */
10+ public class leapYear {
11+ public static void main (String []args ){
12+ Scanner sc = new Scanner (System .in );
13+ int year ;
14+ System .out .println ("Please enter Number to cheack" );
15+ year =sc .nextInt ();
16+ if ( year % 4 == 0 ){
17+ if (year % 100 == 0 ){
18+ if ( year % 400 == 0 )
19+ System .out .println ("Number is Leap year" );
20+ else
21+ System .out .println ("Not a Leap Year" );
22+ }
23+ else
24+ System .out .println ("Number is leap Year" );
25+
26+ }
27+ else
28+ System .out .println ("Not a Leap Year" );
29+ }
30+
31+ }
Original file line number Diff line number Diff line change 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 nazimacadviw ;
7+
8+ /**
9+ *
10+ * @author Nazim
11+ */
12+ class math {
13+
14+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Q.7 Given Number palindrom or Not?
3+ */
4+ package nazimacadviw ;
5+ import java .util .*;
6+ /**
7+ *
8+ * @author Nazim
9+ */
10+ public class palindromOrNot {
11+ public static void main (String []args ){
12+ Scanner sc =new Scanner (System .in );
13+ int num ,sum =0 ,temp ,r ;
14+ System .out .println ("Enter number find Palindrom or Not:" );
15+ num =sc .nextInt ();
16+ temp =num ;
17+ while (num >0 )
18+ {
19+ r =num % 10 ;
20+ sum =(sum *10 )+r ;
21+ num =num /10 ;
22+ }
23+
24+ if (temp ==sum )
25+ System .out .println ("No is Palindrom" );
26+ else
27+ System .out .print ("Number is Not Palindrom" );
28+
29+ }
30+
31+ }
Original file line number Diff line number Diff line change 1+ /*
2+ *
3+ **
4+ ***
5+ ****
6+ */
7+ package nazimacadviw ;
8+
9+ /**
10+ *
11+ * @author Nazim
12+ */
13+ public class patern {
14+ public static void main (String []args ){
15+ for (int i =1 ;i <=5 ;i ++){
16+ for (int j =1 ;j <=5 ;j ++)
17+ {
18+ if (j <i )
19+ System .out .print ("*" ) ;
20+ }
21+ System .out .println ();
22+ }
23+ }
24+
25+ }
Original file line number Diff line number Diff line change 1+ /*
2+ Q2.1 write a java program to print the following patern.
3+ *****
4+ ****
5+ ***
6+ **
7+ *
8+
9+ */
10+ package nazimacadviw ;
11+
12+ /**
13+ *
14+ * @author Nazim
15+ */
16+ public class patern2 {
17+ public static void main (String []args ){
18+ for (int i =1 ;i <=6 ;i ++){
19+ for (int j =1 ;j <=6 ;j ++)
20+ {
21+ if (i <j )
22+ System .out .print ("*" ) ;
23+ }
24+ System .out .println ();
25+ }
26+ }
27+
28+ }
You can’t perform that action at this time.
0 commit comments