Monday, December 4, 2017
Friday, November 24, 2017
Watch Goosebumps (2015) Online Full Movie Free | Gomovies
Watch Goosebumps (2015) Online Full Movie Free | Gomovies: Watch Goosebumps (2015) Online Full Movie Free on Gomovies , Goosebumps (2015) Online in HD with subtitle on 123Movies.
Wednesday, November 22, 2017
Friday, April 14, 2017
Write a program to Get numbers from String
- public class StringReplace {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String str = "ha656rishwajhd8676676r";
- System.out.println("enput string is= "+str);
- String strstr;
- strstr=str.replaceAll("[a-z]", "");
- System.out.println(strstr);
- }
- }
Output:6568676676
Print Even Numbers From Given Array
- Print Even Numbers From Given Array
- import java.util.Scanner;
- public class EvenFinder {
- public static void main(String[] args) {
- int arr[]={1,2,3,4,5,6,7,8,9,10};
- for (int i = 0; i <= arr.length; i++) {
- if(i%2==0){
- System.out.print(i+" ");
- }
- }
- }
- }
Output:
2 4 6 8 10
Wednesday, April 12, 2017
java program to print square of stars
- package day2;
- import java.util.Scanner;
- public class PrintSquareBox {
- public static void main(String[] args) {
- int num = 5;
- for (int i = 0; i < num; i++) {
- System.out.print("3 ");
- }
- System.out.println();
- for (int j = 0; j < num - 2; j++) {
- for (int i = 0; i < num; i++) {
- if (i == 0 || i == num - 1) {
- System.out.print("3 ");
- } else {
- System.out.print("1 ");
- }
- }
- System.out.println();
- }
- for (int i = 0; i < num; i++) {
- System.out.print("3 ");
- }
- }
- }
Output:
To print sum of digits:
- To print sum of digits:
- public class SumOfDigits {
- public static void main(String[] args) {
- int num = 67;
- System.out.println(getSumOfDigits(num));
- }
- public static int getSumOfDigits(int num) {
- int sum = 0;
- if(num<0)
- {
- return -3;
- }else if(num>99){
- return -2;
- }else if(num>0&&num<9){
- return -1;
- }
- while (num > 0) {
- int rem = num % 10;
- sum = sum + rem;
- num = num / 10;
- }
- return sum;
- }
- }
Output:13
Monday, April 3, 2017
To check the given number is Amstrong or Not
package date24;
public class Amstrong {
public static void main(String[] args) {
int first = 153;
int num = first;
int digits = 0;
while (num > 0) {
num = num / 10;
digits++;
}
int s = 0;
int n = first;
while (n > 0) {
int rem = n % 10;
int sum = (int) Math.pow(rem, digits);
n = n / 10;
s = s + sum;
}
if (first == s) {
System.out.println(" the given number is amstrong");
} else {
System.out.println("not amstrong");
}
}
}
OutPut:
the given number is amstrong
public class Amstrong {
public static void main(String[] args) {
int first = 153;
int num = first;
int digits = 0;
while (num > 0) {
num = num / 10;
digits++;
}
int s = 0;
int n = first;
while (n > 0) {
int rem = n % 10;
int sum = (int) Math.pow(rem, digits);
n = n / 10;
s = s + sum;
}
if (first == s) {
System.out.println(" the given number is amstrong");
} else {
System.out.println("not amstrong");
}
}
}
OutPut:
the given number is amstrong
Matrix Addition program using java
Matrix Addition program using java
package day1;
import java.util.Scanner;
public class MatrixAddition {
public static void main(String[] args) {
int a[][] = new int[2][2];
int b[][] = new int[2][2];
int sum[][] = new int[2][2];
Scanner sc = new Scanner(System.in);
System.out.println("enter elements into a");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
a[i][j] = sc.nextInt();
}
}
System.out.println("enter elements into b");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
b[i][j] = sc.nextInt();
}
}
System.out.println("sum is");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
sum[i][j] = a[i][j] + b[i][j];
}
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
System.out.print(sum[i][j] + " ");
}
System.out.println();
}
}
}
OutPut:
enter elements into a
1
2
3
4
enter elements into b
5
6
7
8
sum is
6 8
10 12
package day1;
import java.util.Scanner;
public class MatrixAddition {
public static void main(String[] args) {
int a[][] = new int[2][2];
int b[][] = new int[2][2];
int sum[][] = new int[2][2];
Scanner sc = new Scanner(System.in);
System.out.println("enter elements into a");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
a[i][j] = sc.nextInt();
}
}
System.out.println("enter elements into b");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
b[i][j] = sc.nextInt();
}
}
System.out.println("sum is");
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
sum[i][j] = a[i][j] + b[i][j];
}
}
for (int i = 0; i < 2; i++) {
for (int j = 0; j < 2; j++) {
System.out.print(sum[i][j] + " ");
}
System.out.println();
}
}
}
OutPut:
enter elements into a
1
2
3
4
enter elements into b
5
6
7
8
sum is
6 8
10 12
write a calculator program using Html ans JavaScript
calculator program using HTML and JavaScript:
<HTML>
<HEAD>
<STYLE>
#ab{height:50%;
width:50%;
}
</STYLE>
</HEAD>
<BODY>
<center>
<h1>CALCULATOR<h1>
<FORM NAME="Calc" id="ab">
<center>
<TABLE BORDER=4>
<TR>
<TD>
<INPUT TYPE="text" NAME="Input" Size="16">
<br>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" NAME="one" VALUE=" 1 " OnClick="Calc.Input.value += '1'">
<INPUT TYPE="button" NAME="two" VALUE=" 2 " OnCLick="Calc.Input.value += '2'">
<INPUT TYPE="button" NAME="three" VALUE=" 3 " OnClick="Calc.Input.value += '3'">
<INPUT TYPE="button" NAME="plus" VALUE=" + " OnClick="Calc.Input.value += ' + '">
<br>
<INPUT TYPE="button" NAME="four" VALUE=" 4 " OnClick="Calc.Input.value += '4'">
<INPUT TYPE="button" NAME="five" VALUE=" 5 " OnCLick="Calc.Input.value += '5'">
<INPUT TYPE="button" NAME="six" VALUE=" 6 " OnClick="Calc.Input.value += '6'">
<INPUT TYPE="button" NAME="minus" VALUE=" - " OnClick="Calc.Input.value += ' - '">
<br>
<INPUT TYPE="button" NAME="seven" VALUE=" 7 " OnClick="Calc.Input.value += '7'">
<INPUT TYPE="button" NAME="eight" VALUE=" 8 " OnCLick="Calc.Input.value += '8'">
<INPUT TYPE="button" NAME="nine" VALUE=" 9 " OnClick="Calc.Input.value += '9'">
<INPUT TYPE="button" NAME="times" VALUE=" x " OnClick="Calc.Input.value += ' * '">
<br>
<INPUT TYPE="button" NAME="clear" VALUE=" c " OnClick="Calc.Input.value = ''">
<INPUT TYPE="button" NAME="zero" VALUE=" 0 " OnClick="Calc.Input.value += '0'">
<INPUT TYPE="button" NAME="DoIt" VALUE=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)">
<INPUT TYPE="button" NAME="div" VALUE=" / " OnClick="Calc.Input.value += ' / '">
<br>
</TD>
</TR>
</TABLE>
</FORM>
<BODY>
</HTML>
<HTML>
<HEAD>
<STYLE>
#ab{height:50%;
width:50%;
}
</STYLE>
</HEAD>
<BODY>
<center>
<h1>CALCULATOR<h1>
<FORM NAME="Calc" id="ab">
<center>
<TABLE BORDER=4>
<TR>
<TD>
<INPUT TYPE="text" NAME="Input" Size="16">
<br>
</TD>
</TR>
<TR>
<TD>
<INPUT TYPE="button" NAME="one" VALUE=" 1 " OnClick="Calc.Input.value += '1'">
<INPUT TYPE="button" NAME="two" VALUE=" 2 " OnCLick="Calc.Input.value += '2'">
<INPUT TYPE="button" NAME="three" VALUE=" 3 " OnClick="Calc.Input.value += '3'">
<INPUT TYPE="button" NAME="plus" VALUE=" + " OnClick="Calc.Input.value += ' + '">
<br>
<INPUT TYPE="button" NAME="four" VALUE=" 4 " OnClick="Calc.Input.value += '4'">
<INPUT TYPE="button" NAME="five" VALUE=" 5 " OnCLick="Calc.Input.value += '5'">
<INPUT TYPE="button" NAME="six" VALUE=" 6 " OnClick="Calc.Input.value += '6'">
<INPUT TYPE="button" NAME="minus" VALUE=" - " OnClick="Calc.Input.value += ' - '">
<br>
<INPUT TYPE="button" NAME="seven" VALUE=" 7 " OnClick="Calc.Input.value += '7'">
<INPUT TYPE="button" NAME="eight" VALUE=" 8 " OnCLick="Calc.Input.value += '8'">
<INPUT TYPE="button" NAME="nine" VALUE=" 9 " OnClick="Calc.Input.value += '9'">
<INPUT TYPE="button" NAME="times" VALUE=" x " OnClick="Calc.Input.value += ' * '">
<br>
<INPUT TYPE="button" NAME="clear" VALUE=" c " OnClick="Calc.Input.value = ''">
<INPUT TYPE="button" NAME="zero" VALUE=" 0 " OnClick="Calc.Input.value += '0'">
<INPUT TYPE="button" NAME="DoIt" VALUE=" = " OnClick="Calc.Input.value = eval(Calc.Input.value)">
<INPUT TYPE="button" NAME="div" VALUE=" / " OnClick="Calc.Input.value += ' / '">
<br>
</TD>
</TR>
</TABLE>
</FORM>
<BODY>
</HTML>
output |
Verify a number is Even/Odd
Output
Enter a number which you want to check whether that is even or odd
4
4 is an even number.
Subscribe to:
Posts (Atom)