diff options
author | prathamesh | 2013-07-03 16:58:34 +0530 |
---|---|---|
committer | prathamesh | 2013-07-03 16:58:34 +0530 |
commit | 8de499263ec00be5e500693b8db7f4b5ee0d15bd (patch) | |
tree | a508cfbcd65d16ffb3801a218b6037a8b3bd555f /testapp/java_files | |
parent | 156bb47ecebcca190683b8e59f917a5b742d11fd (diff) | |
parent | b522a1ba1c1edff7648c6c7d69fa2867a08b4100 (diff) | |
download | online_test-8de499263ec00be5e500693b8db7f4b5ee0d15bd.tar.gz online_test-8de499263ec00be5e500693b8db7f4b5ee0d15bd.tar.bz2 online_test-8de499263ec00be5e500693b8db7f4b5ee0d15bd.zip |
Merge branch 'fresh_java' of https://github.com/prathamesh920/online_test into deploy_server
Conflicts:
testapp/templates/exam/question.html
Diffstat (limited to 'testapp/java_files')
-rw-r--r-- | testapp/java_files/main_array_sum.java | 36 | ||||
-rw-r--r-- | testapp/java_files/main_fact.java | 29 | ||||
-rw-r--r-- | testapp/java_files/main_great.java | 39 | ||||
-rw-r--r-- | testapp/java_files/main_hello_name.java | 29 | ||||
-rw-r--r-- | testapp/java_files/main_palindrome.java | 29 | ||||
-rw-r--r-- | testapp/java_files/main_square.java | 32 |
6 files changed, 194 insertions, 0 deletions
diff --git a/testapp/java_files/main_array_sum.java b/testapp/java_files/main_array_sum.java new file mode 100644 index 0000000..5eae299 --- /dev/null +++ b/testapp/java_files/main_array_sum.java @@ -0,0 +1,36 @@ +class main_array_sum +{ + public static <E> void check(E expect, E result) + { + if(result.equals(expect)) + { + System.out.println("Correct:\nOutput expected "+expect+" and got "+result); + } + else + { + System.out.println("Incorrect:\nOutput expected "+expect+" but got "+result); + System.exit(1); + } + } + public static void main(String arg[]) + { + int result; + Test t = new Test(); + int x[] = {0,0,0,0,0}; + result = t.array_sum(x); + System.out.println("Input submitted to the function: {0,0,0,0,0}"); + check(0, result); + int a[] = {1,2,3,4,5}; + result = t.array_sum(a); + System.out.println("Input submitted to the function: {1,2,3,4,5}"); + check(15, result); + int b[] = {1,2,3,0,0}; + result = t.array_sum(b); + System.out.println("Input submitted to the function: {1,2,3,0,0}"); + check(6, result); + int c[] = {1,1,1,1,1}; + result = t.array_sum(c); + System.out.println("Input submitted to the function: {1,1,1,1,1}"); + check(5, result); + } +} diff --git a/testapp/java_files/main_fact.java b/testapp/java_files/main_fact.java new file mode 100644 index 0000000..325dab6 --- /dev/null +++ b/testapp/java_files/main_fact.java @@ -0,0 +1,29 @@ +class main_fact +{ + public static <E> void check(E expect, E result) + { + if(result.equals(expect)) + { + System.out.println("Correct:\nOutput expected "+expect+" and got "+result); + } + else + { + System.out.println("Incorrect:\nOutput expected "+expect+" but got "+result); + System.exit(1); + } + } + public static void main(String arg[]) + { + Test t = new Test(); + int result; + result = t.factorial(0); + System.out.println("Input submitted to the function: 0"); + check(1, result); + result = t.factorial(3); + System.out.println("Input submitted to the function: 3"); + check(6, result); + result = t.factorial(4); + System.out.println("Input submitted to the function: 4"); + check(24, result); + } +} diff --git a/testapp/java_files/main_great.java b/testapp/java_files/main_great.java new file mode 100644 index 0000000..4bfcb1f --- /dev/null +++ b/testapp/java_files/main_great.java @@ -0,0 +1,39 @@ +class main_great +{ + public static <E> void check(E expect, E result) + { + if(result.equals(expect)) + { + System.out.println("Correct:\nOutput expected "+expect+" and got "+result); + } + else + { + System.out.println("Incorrect:\nOutput expected "+expect+" but got "+result); + System.exit(1); + } + } + public static void main(String arg[]) + { + Test t = new Test(); + int result; + result = t.greatest(1, 3, 4); + System.out.println("Input submitted to the function: 1, 3, 4"); + check(4, result); + result = t.greatest(5, 10, 3); + System.out.println("Input submitted to the function: 5, 10, 3"); + check(10, result); + result = t.greatest(6, 1, 4); + System.out.println("Input submitted to the function: 6, 1, 4"); + check(6, result); + result = t.greatest(6, 11, 14); + System.out.println("Input submitted to the function: 6, 11, 14"); + check(14, result); + result = t.greatest(3, 31, 4); + System.out.println("Input submitted to the function: 3, 31, 4"); + check(31, result); + result = t.greatest(26, 13, 3); + System.out.println("Input submitted to the function: 26, 13, 3"); + check(26, result); + + } +} diff --git a/testapp/java_files/main_hello_name.java b/testapp/java_files/main_hello_name.java new file mode 100644 index 0000000..84bb282 --- /dev/null +++ b/testapp/java_files/main_hello_name.java @@ -0,0 +1,29 @@ +class main_hello_name +{ + public static <E> void check(E expect, E result) + { + if(result.equals(expect)) + { + System.out.println("Correct:\nOutput expected "+expect+" and got "+result); + } + else + { + System.out.println("Incorrect:\nOutput expected "+expect+" but got "+result); + System.exit(1); + } + } + public static void main(String arg[]) + { + Test t = new Test(); + String result; + result = t.hello_name("Raj"); + System.out.println("Input submitted to the function: 'Raj'"); + check("hello Raj", result); + result = t.hello_name("Pratham"); + System.out.println("Input submitted to the function: 'Pratham'"); + check("hello Pratham", result); + result = t.hello_name("Ram"); + System.out.println("Input submitted to the function: 'Ram'"); + check("hello Ram", result); + } +} diff --git a/testapp/java_files/main_palindrome.java b/testapp/java_files/main_palindrome.java new file mode 100644 index 0000000..bd463e5 --- /dev/null +++ b/testapp/java_files/main_palindrome.java @@ -0,0 +1,29 @@ +class main_palindrome +{ + public static <E> void check(E expect, E result) + { + if(result.equals(expect)) + { + System.out.println("Correct\n:Output expected "+expect+" and got "+result); + } + else + { + System.out.println("Incorrect:\nOutput expected "+expect+" but got "+result); + System.exit(1); + } + } + public static void main(String arg[]) + { + Test t = new Test(); + boolean result; + result= t.palindrome(123); + System.out.println("Input submitted to the function: 123"); + check(false, result); + result = t.palindrome(151); + System.out.println("Input submitted to the function: 151"); + check(true, result); + result = t.palindrome(23432); + System.out.println("Input submitted to the function: 23432"); + check(true, result); + } +} diff --git a/testapp/java_files/main_square.java b/testapp/java_files/main_square.java new file mode 100644 index 0000000..5cb8c35 --- /dev/null +++ b/testapp/java_files/main_square.java @@ -0,0 +1,32 @@ +class main_square +{ + public static <E> void check(E expect, E result) + { + if(result.equals(expect)) + { + System.out.println("Correct:\nOutput expected "+expect+" and got "+result); + } + else + { + System.out.println("Incorrect:\nOutput expected "+expect+" but got "+result); + System.exit(1); + } + } + public static void main(String arg[]) + { + Test t = new Test(); + int result, input, output; + input = 0; output = 0; + result = t.square_num(input); + System.out.println("Input submitted to the function: "+input); + check(output, result); + input = 5; output = 25; + result = t.square_num(input); + System.out.println("Input submitted to the function: "+input); + check(output, result); + input = 6; output = 36; + result = t.square_num(input); + System.out.println("Input submitted to the function: "+input); + check(output, result); + } +} |