Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/bin/
/kjbbfkjad
/dkjqwhkjd/khbdw/
/wqjdkhlk
Empty file added README
Empty file.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# JavaProgrammingA2Z
Source codes for the book Java Programming A2Z by Dr. Mokter Hossain
14 changes: 0 additions & 14 deletions src/JavaBook1Codes/J02_00.java

This file was deleted.

30 changes: 30 additions & 0 deletions src/chapter00/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package chapter00;

/* 1. */ /* HelloWorld.java */
/* 2. */ /* A Sample Java Application Program */

/* 3. */ public class HelloWorld {

/* 5. */ public static void main(String args[])
/* 6. */ {
/* 7. */ System.out.println("Hello World!");
/* 8. */ System.out.print("Welcome to Java Programming");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");

/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");
/* 9. */ System.out.print("\nThis is my First Java Program");


/* 10.*/ } // End of main()

/* 11.*/} // End of class
36 changes: 36 additions & 0 deletions src/chapter00/MonthDayCalculator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package chapter00;
/**
* MonthDayCalculator.java
*/
import java.io.File;
import java.io.IOException;
import java.util.Random;
public class MonthDayCalculator {
public static void main(String[] args) throws IOException {
// int yearNum = 0;
Random randomNumY = new Random();
int yearNum = randomNumY.nextInt(10001);
int numDays = 0;
Random randomNumM = new Random();
int monthNum = randomNumM.nextInt(13);

switch (monthNum) {
case 1: case 3: case 5: case 7: case 8: case 10: case 12:
numDays = 31; break;
case 4: case 6: case 9: case 11:
numDays = 30; break;
case 2:
if (((yearNum % 4 == 0) && !(yearNum % 100 == 0))||(yearNum % 400 == 0))
numDays = 29;
else
numDays = 28;
break;
default:
System.out.println("Oops!! Invalid month, please run again.");
break;

}

System.out.println("In year " + yearNum + " month #"+ monthNum + " has/had " + numDays + " days");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter02;

/* 1. */ /* J02_01.java */
/* 2. */ /* A Sample Java Application Program */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter02;

public class J02_02 {

Expand Down
Binary file added src/chapter02/J02_03.class
Binary file not shown.
8 changes: 4 additions & 4 deletions src/JavaBook1Codes/J02_03.java → src/chapter02/J02_03.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package JavaBook1Codes;
package chapter02;
/* J02_03.java */
/* A Command Line Argumented Program */

class J02_03{
public class J02_03{

public static void main (String args[])
{
public static void main (String[] args )
{
int i, c;
String S;
c = args.length;
Expand Down
18 changes: 18 additions & 0 deletions src/chapter03/BooleanEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package chapter03;
/* BooleanEx1.java */
/* Working with boolean type Variable */
public class BooleanEx1{
public static void main(String args[]) {
boolean x, y;
x = true; y = false;
System.out.println("x= " +x);
System.out.println("y= " +y);

int x1, y1; boolean z1;
x1 = 15; y1 = 10;
System.out.println("x1>y1 is " +(x1>y1));
z1 = y1>x1;
System.out.println("y1>x1 is " +z1);

}
}
14 changes: 14 additions & 0 deletions src/chapter03/ByteEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package chapter03;
/* ByteEx1.java */
/* ERROR IN RUNNING */
public class ByteEx1{
public static void main(String args[]) {
//byte Value1 = 1000; // Illegal Assigning
//short Value2 = 100000; // Illegal Assigning
byte Value1 = 100; // Legal Assigning
short Value2 = 1000; // Legal Assigning

System.out.println("Value1: " +Value1);
System.out.println("Value2: " +Value2);
}
}
10 changes: 10 additions & 0 deletions src/chapter03/CharEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package chapter03;
/* CharEx1.java */
/* Assigning value to character variables */
public class CharEx1{
public static void main(String args[]) {
char Ch1 = 65, Ch2= 'A';
System.out.println("Ch1: " +Ch1);
System.out.println("Ch2: " +Ch2);
}
}
17 changes: 17 additions & 0 deletions src/chapter03/DoubleEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package chapter03;
/* DoubleEx1.java */
/* ERROR IN RUNNING */
public class DoubleEx1{
public static void main(String args[]) {
float Value1, Value2, Sum;
// Value1 = 3.123456789; // Illegal
// Value2 = 350.0; // Illegal
Value1 = 3.123456789f; // Legal
Value2 = 350.0f; // Legal

Sum = Value1 + Value2;
System.out.println("Value1 = " +Value1);
System.out.println("Value2 = " +Value2);
System.out.println("Sum = " +Sum);
}
}
31 changes: 31 additions & 0 deletions src/chapter03/InputStreamReaderEx1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package chapter03;
/* InputStreamReaderEx1.java */
/* Converting String Object to Corresponding Wrapper Class Objct using valueOf() Method */
import java.io.*;
public class InputStreamReaderEx1{
public static void main(String args[]) {
Integer Roll; // Roll is wrapper class object
String Name;
Float Mark; // Mark is wrapper class object
String S1, S2;
InputStreamReader IN = new InputStreamReader(System.in);
BufferedReader BR = new BufferedReader (IN);
try{
System.out.print("Enter Roll: ");
S1 = BR.readLine();
Roll = Integer.valueOf(S1);
System.out.print("Enter Name: ");
Name = BR.readLine();
System.out.print("Enter Mark: ");
S2 = BR.readLine();
Mark = Float.valueOf(S2);
System.out.println("Roll is : " +Roll);
System.out.println("Name is : " +Name);
System.out.println("Mark is : " +Mark);
}
catch(Exception e)
{
System.out.println("Exception No: " +e);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_01 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_02 {

Expand Down
6 changes: 3 additions & 3 deletions src/JavaBook1Codes/J03_03.java → src/chapter03/J03_03.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package JavaBook1Codes;
package chapter03;

public class J03_03 {

public static void main(String[] args) {
// TODO Auto-generated method stub
char Ch1 = 65, Ch2= 'A';
System.out.println("Ch1 is " +Ch1);
System.out.println("Ch2 is " + Ch2);
System.out.println("Ch1 is: " +Ch1);
System.out.println("Ch2 is " + Ch2);

}

Expand Down
4 changes: 2 additions & 2 deletions src/JavaBook1Codes/J03_04.java → src/chapter03/J03_04.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_04 {

Expand All @@ -9,7 +9,7 @@ public static void main(String[] args) {
// Should not be char Ch = 'AB'


System.out.println("Ch is " +Ch);
System.out.println("Ch is: " +Ch);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_05 {

Expand Down
7 changes: 4 additions & 3 deletions src/JavaBook1Codes/J03_08.java → src/chapter03/J03_08.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package JavaBook1Codes;
package chapter03;

public class J03_08 {

public static void main(String[] args) {
// TODO Auto-generated method stub
byte Value1 = 100;
short Value2 = 10000;
short Value2 = 1000;

int Mul;
Mul = Value1 * Value2; //Illegal Assignment
System.out.println("Value1: " +Value1);
System.out.println("Value2: " +Value2);
System.out.println("Mul : " +Mul);
System.out.println("Mul: " +Mul);


}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_09 {

Expand Down
11 changes: 7 additions & 4 deletions src/JavaBook1Codes/J03_10.java → src/chapter03/J03_10.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_10 {

Expand All @@ -11,12 +11,15 @@ public static void main(String[] args) {
long Distance;
Distance = Year * 365 * 24 * 60 * 60 * LightSpeed;

System.out.println("This is incorrect result.....");
System.out.println("This is incorrect result...");

System.out.println("This is incorrect result...");



System.out.print("In " + Year + " years ");
System.out.print("light will travel about ");
System.out.print(Distance + " miles");

System.out.print(Distance + "miles");
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_12 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_13 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_14 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_15 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_16 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

public class J03_17 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;
//import java.io.DataInputStream;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

import java.io.IOException;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;


import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

import java.io.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

import java.io.IOException;
import java.util.Scanner;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package JavaBook1Codes;
package chapter03;

import java.io.IOException;
import java.util.Scanner;
Expand Down
Loading