Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java Training Source Code - AY #22

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
40 changes: 40 additions & 0 deletions BubbleSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import java.util.*;

public class BubbleSort
{
public static void main(String args[])
{
if (args.length == 0){
System.out.println("Usage Factorial <numeric-number>");
return;
}
int data[] = new int[args.length];
int i, j;

//Fill Data
for(i=0;i<args.length;i++){
data[i] = Integer.parseInt(args[i]);
}

//Bubble Sort
int temp;
for(i=0;i<data.length-1;i++){
for(j=i+1;j<data.length;j++){
if (data[i] > data[j]){
temp = data[i];
data[i] = data[j];
data[j] = temp;
}
}
}
//FastWay
//Arrays.sort(data);

//Print Out
System.out.println("Sorted Data:");
for (i=0;i<data.length;i++){
if (i != 0) System.out.print(" ");
System.out.print(data[i]);
}
}
}
42 changes: 42 additions & 0 deletions Calendar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import java.util.*;

public class Calendar
{
public static void main(String args[])
{
if (args.length != 1){
System.out.println("Usage Calendar <numeric-month>");
return;
}
int mnth = Integer.parseInt(args[0]);

switch (mnth){
case 1:
System.out.println("Month = January"); break;
case 2:
System.out.println("Month = February"); break;
case 3:
System.out.println("Month = March"); break;
case 4:
System.out.println("Month = April"); break;
case 5:
System.out.println("Month = May"); break;
case 6:
System.out.println("Month = June"); break;
case 7:
System.out.println("Month = July"); break;
case 8:
System.out.println("Month = August"); break;
case 9:
System.out.println("Month = September"); break;
case 10:
System.out.println("Month = October"); break;
case 11:
System.out.println("Month = November"); break;
case 12:
System.out.println("Month = Desember"); break;
default:
System.out.println("Range Month are 1 - 12!");
}
}
}
43 changes: 43 additions & 0 deletions Calendar_2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import java.util.*;

public class Calendar_2
{
public static void main(String args[])
{
if (args.length != 2){
System.out.println("Usage Calendar <numeric-year> <numeric-month>");
return;
}

int year = Integer.parseInt(args[0]);
int month = Integer.parseInt(args[1]);
int day = 0;
boolean leapy = false;

if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)){
leapy = true;
}

switch (month){
case 2:
day = leapy ? 29 : 28; break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
day = 31; break;
case 4:
case 6:
case 9:
case 11:
day = 30; break;
default:
System.out.println("Range Month are 1 - 12!");

}
System.out.println("Day = " + day);
}
}
19 changes: 19 additions & 0 deletions Factorial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.*;

public class Factorial
{
public static void main(String args[])
{
if (args.length != 1){
System.out.println("Usage Factorial <numeric-number>");
return;
}
int n = Integer.parseInt(args[0]);
int sum = 1;

for(int i=2;i<=n;i++){
sum *= i;
}
System.out.println("Sum = " + sum);
}
}
20 changes: 20 additions & 0 deletions FactorialRecurrent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.*;

public class FactorialRecurrent
{
public static int fac(int x){
if (x == 1) return 1;
return x * fac(x-1);
}

public static void main(String args[])
{
if (args.length != 1){
System.out.println("Usage Factorial <numeric-number>");
return;
}
int n = Integer.parseInt(args[0]);

System.out.println("Sum = " + fac(n));
}
}
9 changes: 9 additions & 0 deletions HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import java.util.*;

public class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World!");
}
}
32 changes: 32 additions & 0 deletions LetterGrade.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.*;

public class LetterGrade
{
public static void main(String args[])
{
if (args.length != 1){
System.out.println("Usage LetterGrade <numeric-score>");
return;
}
int score = Integer.parseInt(args[0]);
/*
Scanner scan = new Scanner(System.in);

System.out.print("Score = ");

score = scan.nextInt();
*/
if (score > 80){
System.out.println("Grade = A");
}
else if (score > 70){
System.out.println("Grade = B");
}
else if (score > 60){
System.out.println("Grade = C");
}
else{
System.out.println("Grade = D");
}
}
}
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# training-java-future-program
# training-java-future-program

Batch 3.0

@Andy Yusuf 2018

BliBli.Com