This is a small blog for programming.I want to share my thinking,creation and learning to all of you.I also want to develop my own skill as well as yours.
Tuesday, November 10, 2015
Sunday, November 8, 2015
My First Android App
This is my first android app BDTEAM.
You can download it and install to your android phone. The link is below....
Download link
Monday, October 26, 2015
Monday, October 19, 2015
Tuesday, June 9, 2015
Print Fibonacci Series In Java
Program:
package beforeburn;
import java.util.Scanner;
public class Practice1 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the limit of the fibonacci series:");
int userInput = sc.nextInt();
int variable1=1;
int variable2=0;
int fibonacciResult=0;
System.out.println("Finally the fibonacci series is:");
for (int point=0; point<=userInput;point++) {
System.out.print(fibonacciResult+" ");
fibonacciResult=variable1+variable2;
variable1=variable2;
variable2=fibonacciResult;
}
}
}
Output:
Enter the limit of the fibonacci series:
10
Finally the fibonacci series is:
0 1 1 2 3 5 8 13 21 34 55
package beforeburn;
import java.util.Scanner;
public class Practice1 {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the limit of the fibonacci series:");
int userInput = sc.nextInt();
int variable1=1;
int variable2=0;
int fibonacciResult=0;
System.out.println("Finally the fibonacci series is:");
for (int point=0; point<=userInput;point++) {
System.out.print(fibonacciResult+" ");
fibonacciResult=variable1+variable2;
variable1=variable2;
variable2=fibonacciResult;
}
}
}
Output:
Enter the limit of the fibonacci series:
10
Finally the fibonacci series is:
0 1 1 2 3 5 8 13 21 34 55
Screenshots
Program
Output
Friday, March 20, 2015
Print Pass Fail By Scanner And Continuous Using Method
Program:
package passfailproject;
import java.util.Scanner;
public class Checkpassfail {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
int inputMark;
System.out.println("Enter -1 to exit the program");
System.out.println("Enter Your mark that you have got");
inputMark=sc.nextInt();
while(inputMark!=-1){
yourresult(inputMark);
System.out.println("Enter your mark again");
inputMark=sc.nextInt();
}
System.out.println("You have exited the program");
}
static public void yourresult(int mark) {
if(mark<50){
System.out.println("You have Failed");
}else{
System.out.println("You Have Passed");
}
}
}
Output:
Enter -1 to exit the program
Enter Your mark that you have got
60
You Have Passed
Enter your mark again
56
You Have Passed
Enter your mark again
49
You have Failed
Enter your mark again
76
You Have Passed
Enter your mark again
-1
You have exited the program
package passfailproject;
import java.util.Scanner;
public class Checkpassfail {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
int inputMark;
System.out.println("Enter -1 to exit the program");
System.out.println("Enter Your mark that you have got");
inputMark=sc.nextInt();
while(inputMark!=-1){
yourresult(inputMark);
System.out.println("Enter your mark again");
inputMark=sc.nextInt();
}
System.out.println("You have exited the program");
}
static public void yourresult(int mark) {
if(mark<50){
System.out.println("You have Failed");
}else{
System.out.println("You Have Passed");
}
}
}
Output:
Enter -1 to exit the program
Enter Your mark that you have got
60
You Have Passed
Enter your mark again
56
You Have Passed
Enter your mark again
49
You have Failed
Enter your mark again
76
You Have Passed
Enter your mark again
-1
You have exited the program
Screenshots
Program
Output
Monday, March 2, 2015
Object and Classes::public,private,default,constructor method,instance method In Java
Program:
package newfifthlecture;
public class Learnnewclass {
public int aNewnumber=12;//example
static public Carclass myCar;//creating new object
static public Carclass myanothercarCar;//creating another new object
public static void main(String[] args) {
myCar=new Carclass();//calling
System.out.println("Car manufacturer name: "+ myCar.getManufacturerName());
myanothercarCar=new Carclass("TOYOTA","Corolla", 230);//calling and initialize
System.out.println("modelname of my car: "+myanothercarCar.modelName);
}
}
New class in same package:
package newfifthlecture;
public class Carclass {
private String manufacturerName;
public String modelName;
private double fuelAmount;
public Carclass() {
//constructor method
manufacturerName=new String();
modelName="Allion";
fuelAmount=30;
}
public Carclass(String manu,String model,double fuel) {
//another constructor method
manufacturerName=manu;
modelName=model;
fuelAmount=fuel;
}
public String getManufacturerName(){
// instance method
return manufacturerName;
}
}
Output:
Car manufacturer name:
modelname of my car: Corolla
package newfifthlecture;
public class Learnnewclass {
public int aNewnumber=12;//example
static public Carclass myCar;//creating new object
static public Carclass myanothercarCar;//creating another new object
public static void main(String[] args) {
myCar=new Carclass();//calling
System.out.println("Car manufacturer name: "+ myCar.getManufacturerName());
myanothercarCar=new Carclass("TOYOTA","Corolla", 230);//calling and initialize
System.out.println("modelname of my car: "+myanothercarCar.modelName);
}
}
New class in same package:
package newfifthlecture;
public class Carclass {
private String manufacturerName;
public String modelName;
private double fuelAmount;
public Carclass() {
//constructor method
manufacturerName=new String();
modelName="Allion";
fuelAmount=30;
}
public Carclass(String manu,String model,double fuel) {
//another constructor method
manufacturerName=manu;
modelName=model;
fuelAmount=fuel;
}
public String getManufacturerName(){
// instance method
return manufacturerName;
}
}
Output:
Car manufacturer name:
modelname of my car: Corolla
Screenshots
program 1:
program 2:
output
Sunday, March 1, 2015
Project Two for Java: Pascal's Triangle
Program:
package fourthlecture;
import java.util.Scanner;
public class Pascaltriangle {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Enter -1 to exit ");
System.out.println("Please give a number which you convert pascal triangle: ");
int yourchoice=sc.nextInt();
while(yourchoice !=-1){
if(yourchoice <-1 || yourchoice>20){
System.out.println("Please input a value between 1~20 ");
yourchoice=sc.nextInt();
continue;
}
pascaltrianglee(yourchoice);
System.out.println("\n\n");
System.out.println("Please input a value between 1~20 ");
yourchoice=sc.nextInt();
}
System.out.println("You have exited the program.");
}
static void pascaltrianglee(int length){
int[][] pascal = new int[length][length];
for(int i=0;i<length;i++){
pascal[0][i]=1;
pascal[i][0]=1;
}
for(int row=1;row<length;row++){
for(int column=1;column<length-row;column++){
pascal[row][column]=pascal[row][column-1]+pascal[row-1][column];
}
}
for(int row=0;row<length;row++){
for(int column=0;column<length-row;column++){
System.out.print(pascal[row][column]+"\t");
}
System.out.println("\n");
}
}
}
Output:
Enter -1 to exit
Please give a number which you convert pascal triangle:
5
1 1 1 1 1
1 2 3 4
1 3 6
1 4
1
Please input a value between 1~20
6
1 1 1 1 1 1
1 2 3 4 5
1 3 6 10
1 4 10
1 5
1
Please input a value between 1~20
-1
You have exited the program.
package fourthlecture;
import java.util.Scanner;
public class Pascaltriangle {
static Scanner sc=new Scanner(System.in);
public static void main(String[] args) {
System.out.println("Enter -1 to exit ");
System.out.println("Please give a number which you convert pascal triangle: ");
int yourchoice=sc.nextInt();
while(yourchoice !=-1){
if(yourchoice <-1 || yourchoice>20){
System.out.println("Please input a value between 1~20 ");
yourchoice=sc.nextInt();
continue;
}
pascaltrianglee(yourchoice);
System.out.println("\n\n");
System.out.println("Please input a value between 1~20 ");
yourchoice=sc.nextInt();
}
System.out.println("You have exited the program.");
}
static void pascaltrianglee(int length){
int[][] pascal = new int[length][length];
for(int i=0;i<length;i++){
pascal[0][i]=1;
pascal[i][0]=1;
}
for(int row=1;row<length;row++){
for(int column=1;column<length-row;column++){
pascal[row][column]=pascal[row][column-1]+pascal[row-1][column];
}
}
for(int row=0;row<length;row++){
for(int column=0;column<length-row;column++){
System.out.print(pascal[row][column]+"\t");
}
System.out.println("\n");
}
}
}
Output:
Enter -1 to exit
Please give a number which you convert pascal triangle:
5
1 1 1 1 1
1 2 3 4
1 3 6
1 4
1
Please input a value between 1~20
6
1 1 1 1 1 1
1 2 3 4 5
1 3 6 10
1 4 10
1 5
1
Please input a value between 1~20
-1
You have exited the program.
Screenshots
program 1
Program:2
Output
Wednesday, February 25, 2015
Project One for Java : Bookstore For Purchase Book By Perchase
Program:
package firstclass;
import java.util.Scanner;
public class Bookstor {
static Scanner sc = new Scanner(System.in);
static String[] books={"java","c","python"};
static final double ForTeacher=0.5;
static final double ForStudent=0.3;
static final double ForAlien=0.1;
public static void main(String[] args) {
System.out.println("---------------------Welcome to our bookstore------------------");
System.out.println("Which book do you want to purchase??\nAns: ");
String yourchoice=sc.nextLine();
if(books[0].toLowerCase().equals(yourchoice.toLowerCase())){
System.out.println("----You are opted for " +books[0]+ " book-----");
WhichPerson(books[0]);
}else if(books[1].toLowerCase().equals(yourchoice.toLowerCase())){
System.out.println("----You are opted for " +books[1]+ " book-----");
WhichPerson(books[1]);
}else if(books[2].toLowerCase().equals(yourchoice.toLowerCase())){
System.out.println("----You are opted for " +books[2]+ " book");
WhichPerson(books[2]);
}else{
System.out.println("------Sorry your expected book is not available here---------");
}
}
static void WhichPerson(String great){
System.out.println("----Are you teacher,student or alien??\nAns: ");
double price=200;
String mychoice=sc.nextLine();
if(mychoice.toLowerCase().equals("teacher")){
price=price-(price*ForTeacher);
totalprice(price);
}else if(mychoice.toLowerCase().equals("student")){
price=price-(price*ForStudent);
totalprice(price);
}else if(mychoice.toLowerCase().equals("alien")){
price=price-(price*ForAlien);
totalprice(price);
}else{
System.out.println("-----Sorry you are not in this group.So get lost from here-----");
}
}
static void totalprice(double pri){
System.out.println("The total price of your selected book is: "+pri);
System.out.println("------Thank you for shopping--------");
}
}
Output:
---------------------Welcome to our bookstore------------------
Which book do you want to purchase??
Ans:
python
----You are opted for python book
----Are you teacher,student or alien??
Ans:
teacher
The total price of your selected book is: 100.0
------Thank you for shopping--------
package firstclass;
import java.util.Scanner;
public class Bookstor {
static Scanner sc = new Scanner(System.in);
static String[] books={"java","c","python"};
static final double ForTeacher=0.5;
static final double ForStudent=0.3;
static final double ForAlien=0.1;
public static void main(String[] args) {
System.out.println("---------------------Welcome to our bookstore------------------");
System.out.println("Which book do you want to purchase??\nAns: ");
String yourchoice=sc.nextLine();
if(books[0].toLowerCase().equals(yourchoice.toLowerCase())){
System.out.println("----You are opted for " +books[0]+ " book-----");
WhichPerson(books[0]);
}else if(books[1].toLowerCase().equals(yourchoice.toLowerCase())){
System.out.println("----You are opted for " +books[1]+ " book-----");
WhichPerson(books[1]);
}else if(books[2].toLowerCase().equals(yourchoice.toLowerCase())){
System.out.println("----You are opted for " +books[2]+ " book");
WhichPerson(books[2]);
}else{
System.out.println("------Sorry your expected book is not available here---------");
}
}
static void WhichPerson(String great){
System.out.println("----Are you teacher,student or alien??\nAns: ");
double price=200;
String mychoice=sc.nextLine();
if(mychoice.toLowerCase().equals("teacher")){
price=price-(price*ForTeacher);
totalprice(price);
}else if(mychoice.toLowerCase().equals("student")){
price=price-(price*ForStudent);
totalprice(price);
}else if(mychoice.toLowerCase().equals("alien")){
price=price-(price*ForAlien);
totalprice(price);
}else{
System.out.println("-----Sorry you are not in this group.So get lost from here-----");
}
}
static void totalprice(double pri){
System.out.println("The total price of your selected book is: "+pri);
System.out.println("------Thank you for shopping--------");
}
}
Output:
---------------------Welcome to our bookstore------------------
Which book do you want to purchase??
Ans:
python
----You are opted for python book
----Are you teacher,student or alien??
Ans:
teacher
The total price of your selected book is: 100.0
------Thank you for shopping--------
Screenshots
Program:1
Program : 2
Output
Subscribe to:
Posts (Atom)