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
33 changes: 33 additions & 0 deletions BubbleSort.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

public class BubbleSort {

public static void main(String[] args) {
// TODO Auto-generated method stub

if(args.length == 0) {
System.out.println("Usage: LetterGrade <numeric-score>");
return;
}
int data[] = new int[args.length];
int tamp = 0;

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

for(int i=0;i<data.length;i++){
for(int j=0;j<data.length;j++){
if(data[i] < data[j]){
tamp = data[i];
data[i] = data[j];
data [j] = tamp;
}
}
}

for(int i=0;i<data.length;i++){
System.out.println(data[i]);
}

}
}
29 changes: 29 additions & 0 deletions Calendar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

public class Calendar {

public static void main(String[] args) {
// TODO Auto-generated method stub

if(args.length != 1) {
System.out.println("Usage: LetterGrade <numeric-score>");
return;
}

int month = Integer.parseInt(args[0]);
switch(month){
case 1 : System.out.println("January");break;
case 2 : System.out.println("February");break;
case 3 : System.out.println("March");break;
case 4 : System.out.println("April");break;
case 5 : System.out.println("May");break;
case 6 : System.out.println("June");break;
case 7 : System.out.println("July");break;
case 8 : System.out.println("August");break;
case 9 : System.out.println("September");break;
case 10 : System.out.println("October");break;
case 11 : System.out.println("November");break;
case 12 : System.out.println("December");break;
default : System.out.println("Invalid input");break;
}
}
}
32 changes: 32 additions & 0 deletions Day.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

public class Day {

public static void main(String[] args) {
// TODO Auto-generated method stub

if(args.length != 2) {
System.out.println("Usage: LetterGrade <numeric-score>");
return;
}

int month = Integer.parseInt(args[0]);
int year = Integer.parseInt(args[1]);
switch(month){
case 1 :
case 3 :
case 5 :
case 7 :
case 8 :
case 10:
case 12: System.out.println("31 Days");break;
case 4 :
case 6 :
case 9 :
case 11 : System.out.println("30 Days");break;
case 2 : if(year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
System.out.println("29 Days");
else System.out.println("28 Days");break;
default : System.out.println("Invalid input");break;
}
}
}
20 changes: 20 additions & 0 deletions Factorial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

public class Factorial {

public static void main(String[] args) {
// TODO Auto-generated method stub

if(args.length != 1) {
System.out.println("Usage: LetterGrade <numeric-score>");
return;
}

int n = Integer.parseInt(args[0]);
int result = 1;
for(int i=n;i>0;i--){
result *= i;
}

System.out.println(result);
}
}
22 changes: 22 additions & 0 deletions FactorialRecursive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

public class FactorialRecursive {

public static int factorial(int n){
if(n==1){
return n;
}
else return n * factorial(n-1);
}
public static void main(String[] args) {
// TODO Auto-generated method stub

if(args.length != 1) {
System.out.println("Usage: LetterGrade <numeric-score>");
return;
}

int n = Integer.parseInt(args[0]);
int result = factorial(n);
System.out.println(result);
}
}
24 changes: 24 additions & 0 deletions HelloWorld.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

public class HelloWorld {

public static void main(String[] args) {
// TODO Auto-generated method stub

if(args.length != 1) {
System.out.println("Usage: LetterGrade <numeric-score>");
return;
}

int score = Integer.parseInt(args[0]);
if(score > 80){
System.out.println("A");
}
else if(score > 60){
System.out.println("B");
}
else System.out.println("C");


}

}