Wednesday, November 26, 2014

Creating Array List With Scanning In Java

Program:

import java.util.Scanner;
public class practice {
public static void main(String[] args){
int[] public_ara=new int[100];
System.out.println("Enter some numbers: ");
Scanner in=new Scanner(System.in);
for(int j=0;j<5;j++){
public_ara[j]=in.nextInt();
}
System.out.println("Serial\taralist");

for(int i=0;i<5;i++){
System.out.println(i + "\t" +public_ara[i]);
}

}
}

Output:

Enter some numbers: 
15
13
54
21
62
Serial aralist
0 15
1 13
2 54
3 21
4 62

ScreenShot

Program


Output



Tuesday, November 25, 2014

Convert Fahrenheit to Celsius In Java

Program:

import java.util.Scanner;
public class f2c {
public static void main(String[] arrgs){
Scanner in=new Scanner(System.in);
double x,result;
System.out.println("Enter temperature in farenhiet: ");

x=in.nextDouble();
result=((x-32)*5)/9;
System.out.println("The temperature converts into celcius and that is: "+result);

}

}

Output:

Enter temperature in farenhiet:
278.15
The temperature converts into celcius and that is: 136.75

Screenshots

Program


Output



Print Odd or Even Number In java

Program:

package odd_or_even;
import java.util.Scanner;
public class jor_bijor {
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int x;
System.out.println("Enter a number to check: ");
x=in.nextInt();

if(x % 2==0){
System.out.println("The number is even");
}
else{
System.out.println("The number is odd");
}
}
}

Output:

Enter a number to check:
15
The number is odd

Program


Output


Monday, November 17, 2014

GUI==>Graphical User Interface In Java

Program:

package java_tutorial_1;

import javax.swing.JOptionPane;
public class gui {
public static void main(String[] args){
String fn=JOptionPane.showInputDialog("Enter first number: ");
String sn=JOptionPane.showInputDialog("Enter second number: ");

int num1=Integer.parseInt(fn);
int num2=Integer.parseInt(sn);

int res=num1+num2;
JOptionPane.showMessageDialog(null,"answer "+ res,"title", JOptionPane.PLAIN_MESSAGE);
}

}

Screenshots

Program


Output 1


Output 2


Output 3


Friday, November 14, 2014

Twitter

Wednesday, November 12, 2014

Add variables using for loop In Java

Program:

package sum_project;
import java.util.Scanner;
public class summation {
public static void main(String[] args){
Scanner moni=new Scanner(System.in);
int userinput;
int sum=0;

System.out.println("Enter a number: ");
userinput=moni.nextInt();
if(userinput<0){
System.out.println("there are no number : ");
}
else{
for(int i=1;i<=userinput;i++){
sum=sum+i;
}
}
System.out.println("The sum is: "+sum);
}

}

Output:

Enter a number: 
20
The sum is: 210

Screenshot:

Program:


Output:


Mini Project Word Ripp In Java Language

Program:

package wordgame;
import java.util.Scanner;
public class word {
public static void main(String[] args){

String name;
String city;
String district;
String fathername;
String mothername;
String schoolname;
String thana;

Scanner moni=new Scanner(System.in);
System.out.println("Enter your name: ");
name=moni.nextLine();

System.out.println("Enter your city name: ");
city= moni.nextLine();
System.out.println("Enter your district name: ");
district=moni.nextLine();
System.out.println("Enter father name: ");

fathername=moni.nextLine();
System.out.println("Enter your mother name: ");
mothername=moni.nextLine();

System.out.println("Enter your school name: ");
schoolname=moni.nextLine();
System.out.println("Enter your thana name: ");
thana=moni.nextLine();
System.out.println("My name is "+name+ "."+
" I live in "+city+"."+" My father's name is "+fathername+"."+" My mother's name is "
+mothername+ "."+" My school name was "+schoolname+"."+" My district name is                              "+district+"."+
" And the thana is "+thana+".");
}

}
Output:

Enter your name: 
jack
Enter your city name: 
Naraingonj
Enter your district name: 
Dhaka
Enter father name: 
Redclief
Enter your mother name: 
Belly
Enter your school name: 
Udaigar school
Enter your thana name: 
Dhaka
My name is jack. I live in Naraingonj. My father's name is Redclief. My mother's
 name is Belly. My school name was Udaigar school. My district name is Dhaka. An
d the thana is Dhaka.



Screenshots:

Program:


Output:



Mini project Miles per gallon In Java Language

Program:

package milespergalon;
import java.util.Scanner;
  //class method
public class mpg {
//main method
public static void main(String[] args){
double miles_used;
double galon_used;
double mile_per_galon;

Scanner moni=new Scanner(System.in);
System.out.println("How many miles you have driven: ");

miles_used=moni.nextDouble();
System.out.println("How many galons you have used: ");

galon_used=moni.nextDouble();

mile_per_galon=miles_used/galon_used;

System.out.println("Here this is your main result miles per galon is 25" + mile_per_galon);


}

}

Output:

How many miles you have driven: 
30
How many galons you have used: 
12
Here this is your main result miles per galon is 2.5

Screenshot

Program


Output By input Value 30&12


Tuesday, November 11, 2014

Multiple Class In Java

Program:

package nulticlass;

public class multi {
public static void main(String[] args){
multa object=new multa();
object.mela();
object.another_mela();
}
}

public class multa {
public void mela(){
System.out.println("here this is multi class in this program");
}
public void another_mela(){
int a=12,b=48,result=a+b;
System.out.println("the output of the method is "+ result);
}

}

Output:

here this is multi class in this program

the output of the method is 60

Screenshot

Program


Step 1:class



Step 2:Another class

Output





Sunday, November 9, 2014

Embedding PHP on HTML

Program:

<?php
     $teta="last name";
?>
<input type="text" name="name" value="<?php echo $teta; ?>"> 

Screenshot

Program



Output




Indentation In PHP

Indentation:

It means using Curly brackets { } in programming.

<?php
//indentation two types....1.end of line indentation

$text=15;
if($text==15){     //  here this is the end of line indentation
echo 'The number is really fifteen';
}else{
echo 'The number is not fifteen';
}
//  2.next line indentation

$text=12;
if($text==15)
{     //  here this is the next line indentation
echo 'The number is really fifteen';
}
else
{
echo 'The number is not fifteen';
}
?>

Output:

The number is really fifteen
The number is not fifteen 


Screenshots:

Program:


Output


Monday, November 3, 2014

Print Asterisk In Java By increment operator

Program:

package prem1;

public class mohona1 {
public static void main(String[] args){
for(int i=1;i<5;i++){
for(int j=0;j<5-i;j++){
System.out.print(" ");
}
for(int k=0;k<i;k++){
System.out.print("*");
}
System.out.println(" ");
}
}

}

Output:

      *
    **
  ***
****

Screenshots

Program


Output