# Snake and Ladder game In java

আমরা ছোট বেলায় অনেকেই সাপ লুডু খেলেছি এবং এখনো খেলতে পছন্দ করি। যুগ বদলেছে আজ আমরা মাঠে খেলার বদলে খেলি কম্পিউটার এর ছোট্টখানি পর্দায়। তাই আমিও চেস্টা করেছি আমাদের ছোট্ট বেলার সেই খেলাটিকে ডিজিটাল পর্দায় নিয়ে আসতে। যদিও আমার এই খেলাটি অত্যন্ত সাধারণ মানের এবং এর কোন গ্রাফিক্যাল অস্তিত্ব নেই তবুও এটা কিন্তু ডিজিটাল।

# Some Java program part 6

1. Write a Java program that would input three numbers from the user and print sum, then the first number, then the 2nd number followed by 3rd number. If user enters 10, 20, 30. then output should be 60, 10, 20, 30.
```import java.util.Scanner;
public class Lab8q4{
public static void main ( String [] args ){
int [] number = new int ;
int c = 0, sum=0;
Scanner input = new Scanner ( System.in );
System.out.println(&quot;Enter 3 numbers&quot;);
while(c&lt;3){
number  = input.nextInt();
sum = sum + number ;
++c;
}
System.out.println(&quot;SUM : &quot;+sum);
c=0;
while(c&lt;3){
System.out.println(number);
++c;
}
}
}
```
1. Write a Java program that would input ten numbers from the user and print the ten numbers in reverse order. If user enters 20, 10, 30, 15. Then output should be 15, 30, 10, 20.
```import java.util.Scanner;
public class Lab8q5{
public static void main ( String [] args ){
int [] number = new int ;
int c = 0, sum=0;
Scanner input = new Scanner ( System.in );
System.out.println(&quot;Enter 3 numbers&quot;);
while(c&lt;3){
number  = input.nextInt();
sum = sum + number ;
++c;
}
c=2;
while(c&gt;=0){
System.out.println(number);
--c;
}
}
}
```

# Some Java programs part-5

21. Write a program that will calculate the value of Z  if the expression of y is as follows (n is the input): # Some Java programs part 4

16. Write a program that will read 10 numbers from the user, and then print the first number, the sum of the first 2 numbers, first 3 numbers, and so on up to the sum of 20 numbers.

```/*Time : 5:00pm
* Author: Anik das*/
import java.util.Scanner;
public class Faraz16{
public static void main ( String [] args ){
int c=1, sum=0, number;
Scanner input = new Scanner ( System.in );
while (c&lt;=10){
System.out.println(&quot;Enter Number #&quot;+c);
number = input.nextInt();
sum=sum+number;
System.out.println(&quot;Sum Of 1st &quot;+c+&quot; Number(s) is : &quot;+sum);
c++;
}
}
}
```

# A little about array in Java

I have seen many of my friends to have trouble with the problems in array. So, this time I have selected to write with array…don’t know how much effective it would be to you guys…

First of all, what is array? Normally we can say that array is a static memory allocation. For example we can think an array as a number of conjoined boxes where we can store our desired values of same data type. Now the question may arise that we can use normal variables to store data, why use array? The answer is we should use array because it saves our time and minimizes the memory usage of the machine. For example: suppose that you have to store marks of 5000 students of your university. Now if you want to store those marks using normal variables firstly you have to select 5000 variables (which would be horrible!). Then, you will need to declare each variable (int a, b, c…up to 5000 variables). Than you have to initialize each variable too, haven’t you? In this case if you use array your task will become easier. All you have to do is, firstly you have to declare an array. Secondly, you have to initialize that the array will be consist of 5000 indexes it means the array will consist of 5000 conjoined boxes where the marks will be stored.

I have always seen people having problem with the boolean in Java. Boolean can be effective to compress the size of your Java program. Here I have tried to give you a simple idea about boolean to clear confusions about boolean.

# some Java programs part 3

//11//Question: Write a program to compute and display a person’s weekly salary as determined by the following conditions: If the hours worked are less than or equal to 40, the person receives Tk200.00 per hour, else the person receives Tk8000.00 plus Tk300.00 for each hour worked over 40 hours.

```/* Time: 11.35am
* Author: Anik Das
* Question: Write a program to compute and display a person’s weekly salary as determined by
* the following conditions: If the hours worked are less than or equal to 40, the person receives
* Tk200.00 per hour, else the person receives Tk8000.00 plus Tk300.00
* for each hour worked over 40 hours.*/
import java.util.Scanner;
public class Faraz11{
public static void main (String args []){
int workHr, sal=0;
Scanner input = new Scanner ( System.in );
workHr = input.nextInt();
if ( workHr&lt;=40 ){       sal = workHr*200;     }     if ( workHr&gt;40 ){
sal = 8000 + 300*( workHr - 40 );
}
System.out.println(&quot;Yor Sallery Is : Taka &quot;+sal);
}
}

```

//12// question: Write a program, given an “amount” of money. It shows it split into 500, 100, 50, 20, 10, 5, 2 and 1 taka bills or coins. The output would be: Say for 1234 it says:

• 500 Taka: 2 note(s)
• 100 Taka: 2 note(s)
• 50 Taka: 0 note(s)
• 20 Taka: 1 note(s)
• 10 Taka: 1 note(s)
• 5 Taka: 0 note(s)
• 2 Taka: 2 note(s)
• 1 Taka: 0 note(s)
```/* Time: 12:01pm
* Author: Anik Das
* question: Write a program, given an “amount” of money.
* It shows it split into 500, 100, 50, 20, 10, 5, 2 and 1 taka bills or coins. The output would be:
Say for 1234 it says:
500 Taka: 2 note(s)
100 Taka: 2 note(s)
50 Taka: 0 note(s)
20 Taka: 1 note(s)
10 Taka: 1 note(s)
5 Taka: 0 note(s)
2 Taka: 2 note(s)
1 Taka: 0 note(s)*/
import java.util.Scanner;
public class Faraz12 { //original MoneySplit
public static void main (String[]args) {
int oneTaka=0, twoTaka=0, fiveTaka=0, tenTaka=0;
int twentyTaka=0, fiftyTaka=0, hundredTaka=0, fiveHundredTaka=0;
int amount;
Scanner input = new Scanner ( System.in );
amount = input.nextInt();
int K=amount%500;
fiveHundredTaka = (amount - K)/500;
int A=K%100;
hundredTaka=(K-A)/100;
int B=A%50;
fiftyTaka=(A-B)/50;
int C=B%20;
twentyTaka=(B-C)/20;
int D=C%10;
tenTaka=(C-D)/10;
int E=D%5;
fiveTaka=(D-E)/5;
int F=E%2;
twoTaka=(E-F)/2;
int G=F%1;
oneTaka=(F-G)/1;
System.out.println(&quot;500 Taka: &quot;+fiveHundredTaka+&quot; note(s)n100 Taka: &quot;+hundredTaka+&quot; note(s)n50 Taka: &quot;+fiftyTaka+&quot; note(s)n20 Taka: &quot;+twentyTaka+&quot; note(s)n10 Taka: &quot;+tenTaka+&quot; note(s)n5 Taka: &quot;+fiveTaka+&quot; note(s)n2 Taka: &quot;+twoTaka+&quot; note(s)n1 Taka: &quot;+oneTaka+&quot; note(s)&quot;);
}
}

```

# Before you start java programming

There are some prerequisites to start java programming. Make sure have these following things.

1. Software to write JAVA program
2. Java runtime 1.5 or above

For the first one I would recommend Dr.Java as I am much familiar  with it because it’s used in my University. You can find out Dr.Java in Dr.java.org . You cannot run Dr.Java if you do not have java runtime 1.5 or above installed in you machine. To install java in your computer follow the next step.

Happy Programming… 🙂

# Some java programs part 2

##6## A leading newspaper pays all their freelance writers at a rate of Tk. 500 per published article. Draw the flowchart for a program that will read the number of published articles for one writer, and print the total monthly fees for that writer.

```/* time : 5.56pm
* author: Anik*/
import java.util.Scanner;
public class Faraz6 {
public static void main (String [] args) {
Scanner input= new Scanner (System.in);
System.out.println(&quot;Input Number(s) Article&quot;);
int a, fees;
a= input.nextInt();
fees= (a*500);
System.out.println(&quot;Total Fees: &quot;+fees);
}
}
```

##7##Write a program that takes as input your final marks and shows as output the letter grade.

```/*Time: 9:28pm
* Author: Anik Das*/
import java.util.Scanner;
public class Faraz7{
public static void main (String [] args){
Scanner input=new Scanner (System.in);
int n=0;
n=input.nextInt();
if (n&gt;=90){
}else{
if (n&gt;=85){
}else{
if (n&gt;=80){
}else{
if (n&gt;=75){
}else{
if (n&gt;=70){
}else{
if (n&gt;=65){
}else{
if (n&gt;=60){
}else{
if (n&gt;=57){
}else{
if (n&gt;=55){
}else{
if (n&gt;=52){
}else{
if (n&gt;=50){
}else{
}
}
}
}
}
}
}
}
}
}
}
}
}

##8##. Write a flowchart for a program that performs four functions of a calculator. The program should request the user to enter a floating-point number, an operator and another floating-point number. It should then carry out the specified arithmetical operation: adding, subtracting, multiplying, or dividing the two floating-point numbers. Finally, it should display the result.

/*time: 9.59pm
* autthor: Anik Das
* Question: Write a flowchart for a program that performs four functions of a calculator.
* The program should request the user to enter a floating-point number,
* an operator and another floating-point number.
* It should then carry out the specified arithmetical operation:
* adding, subtracting, multiplying, or dividing the two floating-point numbers.
* Finally, it should display the result.*/
import java.util.Scanner;
public class Faraz8{
public static void main (String [] args){
float n, a, s;
Scanner input= new Scanner (System.in);
System.out.println(&quot;ENTER 1ST NUMBER&quot;);
n= input.nextFloat();
System.out.println(&quot;ENTER 2ND NUMBER&quot;);
a= input.nextFloat();
System.out.println(&quot;ENTER OPERATOR.ENTER 0 FOR ADDITION, 1 FOR SUBSTRUCTION, 2 FOR MULTIPLICATION, 3 FOR DIVISIOIN &quot;);
String p;
int x=input.nextInt();
if (x==0){
s=n+a;
}else{
if (x==1){
s=n-a;
}else{
if (x==2){
s=n*a;
}else{
if (x==3){
s=n/a;
}else{
System.out.println(&quot;WRONG OPERATOR&quot;);
}
}
}
}
}
}

(more…)

```

# some java programs part 1

##1##
Write a program to determine whether a number is odd or even.

```/* Time: 5.10pm
* author: Anik
* Question:Write a program to determine whether a number is odd or even.*/
import java.util.Scanner;
public class Faraz1{
public static void main (String [] args){
Scanner input = new Scanner (System.in);
int n=0;
n = input.nextInt();
if (n%2==0){
System.out.println(&quot;THE NUMBER IS EVEN&quot;);
}else{
System.out.println(&quot;THE NIMBER IS ODD&quot;);
}
}
}

```

##2##Write a program that takes three numbers input from the user and find the maximum and the minimum?

```/*Time: 5.20pm
* Author: Anik Das
* Question:Write a program that takes three numbers input from the user
* and find the maximum and the minimum?*/
import java.util.Scanner;
public class Faraz2{
public static void main (String [] args){
Scanner input = new Scanner(System.in);
int a=0, max=0, min=0, c=1, d=2;
a= input.nextInt();
max=a;
min=a;
while (c&lt;=2){
a= input.nextInt();
if (a&gt;=max){
max=a;
c=c+1;
d=d+1;
}else{
if (a&lt;=min){
min=a;
c=c+1;
d=d+1;
}else{
c=c+1;
d=d+1;
}
}
}
System.out.println(&quot;MAX : &quot;+max);
System.out.println(&quot;MIN : &quot;+min);
}
}
```

##3##. Write a program that takes five number input from user and determine their addition and average.

```/*time: 5:37pm
* author: Anik das
* question: Write a program that takes five number input from user
* and determine their addition and average.*/
import java.util.Scanner;
public class Faraz3{
public static void main (String [] args){
Scanner input = new Scanner(System.in);
int a=0, c=1, sum=0, avg=0;
while (c&lt;=5){
System.out.println(&quot;Enter Number &quot;+c);
a = input.nextInt();
sum = sum+a;
c=c+1;
}
avg=sum/5;
System.out.println(&quot;AVERAGE : &quot;+avg);
}
}
```

##4##Write a program that finds CGPA given credits and grade of n courses where n is the user input.

```/* Time: 11.46
* date: 11-02-2011
* Author: Anik Das
*question: Write a program that takes five number input from
* user and determine their addition and average.*/
import java.util.Scanner;
public class Faraz4 {
public static void main (String [] args) {
Scanner input = new Scanner (System.in);
int c, cr, tcr;
double gr, qp, tqp, gpa;
c=1;
tqp=0;
cr=0;
gr=0;
gpa=0.0;
tcr=0;
int n=0;
System.out.println(&quot;Enter Number of courses(n)&quot;);
n=input.nextInt();
while (c&lt;=n)
{System.out.println(&quot;Enter Number of credits for course No. &quot;+c);
cr = input.nextInt();
gr = input.nextDouble();
qp = cr * gr;
tqp = tqp + qp;
tcr = tcr +cr;
c = c + 1;
}
gpa = (tqp/tcr);
System.out.println(&quot;Your GPA for Four courses is: &quot; + gpa);
}
}
```

##5## Write a program for finding area of a rectangle given height and width.

```/* time: 5.54pm
* author: Anik Das
* question: Write a program for finding area of a rectangle given height and width.*/
import java.util.Scanner;
public class Faraz5{
public static void main (String [] args){
Scanner input= new Scanner (System.in);
double w, h, area;
System.out.println(&quot;enter Width&quot;);
w= input.nextDouble();
System.out.println(&quot;enter Height&quot;);
h= input.nextDouble();
area= w*h;
System.out.println(&quot;Area of the Rectangle is &quot;+area);
}
}
```