diff --git a/JPohlmann/Lab4/.idea/misc.xml b/JPohlmann/Lab4/.idea/misc.xml new file mode 100644 index 0000000..fc67c28 --- /dev/null +++ b/JPohlmann/Lab4/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/JPohlmann/Lab4/.idea/modules.xml b/JPohlmann/Lab4/.idea/modules.xml new file mode 100644 index 0000000..ffcf9a6 --- /dev/null +++ b/JPohlmann/Lab4/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/JPohlmann/Lab4/.idea/workspace.xml b/JPohlmann/Lab4/.idea/workspace.xml new file mode 100644 index 0000000..df9964e --- /dev/null +++ b/JPohlmann/Lab4/.idea/workspace.xml @@ -0,0 +1,539 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1521679190301 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + file://$PROJECT_DIR$/src/Palindrome.java + 13 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/JPohlmann/Lab4/Lab4.iml b/JPohlmann/Lab4/Lab4.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/JPohlmann/Lab4/Lab4.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/JPohlmann/Lab4/out/production/Lab4/CannonBall.class b/JPohlmann/Lab4/out/production/Lab4/CannonBall.class new file mode 100644 index 0000000..6cfa362 Binary files /dev/null and b/JPohlmann/Lab4/out/production/Lab4/CannonBall.class differ diff --git a/JPohlmann/Lab4/out/production/Lab4/Palindrome.class b/JPohlmann/Lab4/out/production/Lab4/Palindrome.class new file mode 100644 index 0000000..40a9668 Binary files /dev/null and b/JPohlmann/Lab4/out/production/Lab4/Palindrome.class differ diff --git a/JPohlmann/Lab4/out/production/Lab4/ReverseString.class b/JPohlmann/Lab4/out/production/Lab4/ReverseString.class new file mode 100644 index 0000000..5faa8de Binary files /dev/null and b/JPohlmann/Lab4/out/production/Lab4/ReverseString.class differ diff --git a/JPohlmann/Lab4/out/production/Lab4/Sorting.class b/JPohlmann/Lab4/out/production/Lab4/Sorting.class new file mode 100644 index 0000000..1878080 Binary files /dev/null and b/JPohlmann/Lab4/out/production/Lab4/Sorting.class differ diff --git a/JPohlmann/Lab4/out/production/Lab4/Temperature.class b/JPohlmann/Lab4/out/production/Lab4/Temperature.class new file mode 100644 index 0000000..e21ebf3 Binary files /dev/null and b/JPohlmann/Lab4/out/production/Lab4/Temperature.class differ diff --git a/JPohlmann/Lab4/out/production/Lab4/Triangle.class b/JPohlmann/Lab4/out/production/Lab4/Triangle.class new file mode 100644 index 0000000..5e12a0a Binary files /dev/null and b/JPohlmann/Lab4/out/production/Lab4/Triangle.class differ diff --git a/JPohlmann/Lab4/out/production/Lab4/recursiveFactorial.class b/JPohlmann/Lab4/out/production/Lab4/recursiveFactorial.class new file mode 100644 index 0000000..24035b5 Binary files /dev/null and b/JPohlmann/Lab4/out/production/Lab4/recursiveFactorial.class differ diff --git a/JPohlmann/Lab4/src/CannonBall.java b/JPohlmann/Lab4/src/CannonBall.java new file mode 100644 index 0000000..3db9d16 --- /dev/null +++ b/JPohlmann/Lab4/src/CannonBall.java @@ -0,0 +1,17 @@ +import java.util.Scanner; + +public class CannonBall { + public static void main(String[]args){ + Scanner sysIn= new Scanner(System.in); + int input = sysIn.nextInt(); + double result=cannonBall(input); + System.out.println(result); + } + private static double cannonBall(int input){ + double result=0; + for(int i=input; i>0; i--){ + result+=i; + } + return result; + } +} diff --git a/JPohlmann/Lab4/src/Palindrome.java b/JPohlmann/Lab4/src/Palindrome.java new file mode 100644 index 0000000..aab30c3 --- /dev/null +++ b/JPohlmann/Lab4/src/Palindrome.java @@ -0,0 +1,21 @@ +import java.util.Scanner; + +public class Palindrome { + public static void main(String[]args){ + Scanner scanner = new Scanner(System.in); + System.out.println("Enter the Word"); + String string = scanner.nextLine(); + if(isPal(string)) + System.out.println(string + " is a palindrome"); + else + System.out.println(string + " is not a palindrome"); + } + public static boolean isPal(String s){ + if(s.length()== 0|| s.length() ==1) + return true; + if(s.charAt(0)==s.charAt(s.length()-1)) + return isPal(s.substring(1, s.length()-1)); + return false; + + } +} diff --git a/JPohlmann/Lab4/src/ReverseString.java b/JPohlmann/Lab4/src/ReverseString.java new file mode 100644 index 0000000..ea1f821 --- /dev/null +++ b/JPohlmann/Lab4/src/ReverseString.java @@ -0,0 +1,20 @@ +import java.util.Scanner; + +public class ReverseString { + public static void main(String[]args){ + Scanner sysIn = new Scanner(System.in); + String stringInput= sysIn.next(); + String result = reverseString(stringInput); + System.out.println(result); + } + public static String reverseString (String stringInput){ + int length= stringInput.length(); + char[] reverse = new char[length]; + for(int i = 0; i < length; i++ ){ + reverse[i]= stringInput.charAt(length-1-i); + } + String reverseString1= new String(reverse); + return reverseString1; + + } +} diff --git a/JPohlmann/Lab4/src/Sorting.java b/JPohlmann/Lab4/src/Sorting.java new file mode 100644 index 0000000..c833582 --- /dev/null +++ b/JPohlmann/Lab4/src/Sorting.java @@ -0,0 +1,29 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class Sorting { + public static void main(String[]args){ + System.out.println("What is your List Size?"); + Scanner sysIn = new Scanner(System.in); + int listSize = sysIn.nextInt(); + int[] sorter= new int[listSize]; + Scanner inputNum = new Scanner(System.in); + for(int i=0; i1;i-- ){ + int number2= i-1; + result +="*"+number2; + } + return result; + } +} diff --git a/Lab4 probs b/Lab4 probs new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/Lab4 probs @@ -0,0 +1 @@ + diff --git a/README.md b/README.md index ff2c855..bd8c2ec 100644 --- a/README.md +++ b/README.md @@ -18,5 +18,7 @@ I would like you to complete what you can prior to next Wednesday's Lecture. #### Recursion -* Write a program that takes an integer, and prints the factorial of the integer. ex: 5 factorial is 5*4*3*2*1 -* Write a +* Write a program that takes an integer, and prints the factorial of the integer. ex: 5 factorial is 5 * 4 * 3 * 2 * 1 +* Write a program that will calculate the number of cannon balls in a trinagular pyramid that has the intered integer number of rows. +(Note: this means that any layer of the pyramid has an equalateral triangle of cannonballs. The top layer has 1 cannon ball, the one below that has 3, etc.) +* Use recursion to determin if a string passed in is a palindrome. Your program will be given a string. diff --git a/Skylar Galloway Lab 4/.idea/misc.xml b/Skylar Galloway Lab 4/.idea/misc.xml new file mode 100644 index 0000000..0548357 --- /dev/null +++ b/Skylar Galloway Lab 4/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Skylar Galloway Lab 4/.idea/modules.xml b/Skylar Galloway Lab 4/.idea/modules.xml new file mode 100644 index 0000000..ac45997 --- /dev/null +++ b/Skylar Galloway Lab 4/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Skylar Galloway Lab 4/.idea/vcs.xml b/Skylar Galloway Lab 4/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/Skylar Galloway Lab 4/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Skylar Galloway Lab 4/.idea/workspace.xml b/Skylar Galloway Lab 4/.idea/workspace.xml new file mode 100644 index 0000000..0eb5b72 --- /dev/null +++ b/Skylar Galloway Lab 4/.idea/workspace.xml @@ -0,0 +1,540 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1521679830596 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/dburrigh/dburrigh.iml b/dburrigh/dburrigh.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/dburrigh/dburrigh.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/dburrigh/folder b/dburrigh/folder new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/dburrigh/folder @@ -0,0 +1 @@ + diff --git a/dburrigh/out/production/dburrigh/Recursive1.class b/dburrigh/out/production/dburrigh/Recursive1.class new file mode 100644 index 0000000..e8dc91b Binary files /dev/null and b/dburrigh/out/production/dburrigh/Recursive1.class differ diff --git a/dburrigh/out/production/dburrigh/Recursive2.class b/dburrigh/out/production/dburrigh/Recursive2.class new file mode 100644 index 0000000..b0bb6b7 Binary files /dev/null and b/dburrigh/out/production/dburrigh/Recursive2.class differ diff --git a/dburrigh/out/production/dburrigh/Recursive3.class b/dburrigh/out/production/dburrigh/Recursive3.class new file mode 100644 index 0000000..6bc7214 Binary files /dev/null and b/dburrigh/out/production/dburrigh/Recursive3.class differ diff --git a/dburrigh/out/production/dburrigh/Reverse.class b/dburrigh/out/production/dburrigh/Reverse.class new file mode 100644 index 0000000..30313b7 Binary files /dev/null and b/dburrigh/out/production/dburrigh/Reverse.class differ diff --git a/dburrigh/out/production/dburrigh/Temperature.class b/dburrigh/out/production/dburrigh/Temperature.class new file mode 100644 index 0000000..f7305c5 Binary files /dev/null and b/dburrigh/out/production/dburrigh/Temperature.class differ diff --git a/dburrigh/out/production/dburrigh/Triangle.class b/dburrigh/out/production/dburrigh/Triangle.class new file mode 100644 index 0000000..7898998 Binary files /dev/null and b/dburrigh/out/production/dburrigh/Triangle.class differ diff --git a/dburrigh/src/Recursive1.java b/dburrigh/src/Recursive1.java new file mode 100644 index 0000000..0b02f67 --- /dev/null +++ b/dburrigh/src/Recursive1.java @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class Recursive1 { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + int Integer = scan.nextInt(); + String result = Factorial(Integer); + System.out.print(result); + } + + private static String Factorial(int Integer) + { + String result ="" + Integer; //This is the only way I know how to get this to work + for (int i = Integer; i > 1; i--) + { + int nextInteger = i - 1; + result = result + "*" + nextInteger; + } + return result; + } +} \ No newline at end of file diff --git a/dburrigh/src/Recursive2.java b/dburrigh/src/Recursive2.java new file mode 100644 index 0000000..3ad3be1 --- /dev/null +++ b/dburrigh/src/Recursive2.java @@ -0,0 +1,23 @@ +import java.util.Scanner; + +public class Recursive2 { + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + int Triangle = scan.nextInt(); //this is what we are inputting + float Final = Ball(Triangle); + System.out.print(Final); + } + + public static long Ball(int Triangle) //Ball = Cannonball + { + long Final = 0; //we want to start with 0 + int i = Triangle; + while(i > 0) + { + Final = Final + i; + i--; + } + return Final; + } +} diff --git a/dburrigh/src/Recursive3.java b/dburrigh/src/Recursive3.java new file mode 100644 index 0000000..e9c300e --- /dev/null +++ b/dburrigh/src/Recursive3.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class Recursive3 { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + String input = scan.next(); + System.out.print(Palindrome(input)); + } + + private static boolean Palindrome(String input) + { + int Name = input.length(); + int count = 0; + + for(int i = 0; i < Name; i++) + { + if(input.charAt(i) == input.charAt(Name - i - 1)) //analyze first and last, second and second to last, etc. + { + count++; + } + } + return count == Name; + } +} diff --git a/dburrigh/src/Reverse.java b/dburrigh/src/Reverse.java new file mode 100644 index 0000000..52ad804 --- /dev/null +++ b/dburrigh/src/Reverse.java @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class Reverse { + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + String input = scan.next(); + String result = reverse(input); + System.out.print(result); + } + + public static String reverse(String input) + { + int Name = input.length(); //Want the code to know how long the String is + char[] reverse = new char[Name]; + int i = 0; + + while(i < Name) + { + reverse[i] = input.charAt(Name-i-1); + i++; //keep going until all characters have been run through + } + String output = new String(reverse); + return output; + } +} diff --git a/dburrigh/src/Sorting.java b/dburrigh/src/Sorting.java new file mode 100644 index 0000000..b8c877e --- /dev/null +++ b/dburrigh/src/Sorting.java @@ -0,0 +1,31 @@ +import java.util.Scanner; +import java.util.List; + +public class Sorting { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + int Amount; //number of integers + int List[] = new int[Amount]; + + for (int i = 0; i < Amount; i++) + { + Amount = scan.nextInt(); + List[i] = scan.nextInt(); + } + int i = 0; + while (i < Amount) { + System.out.print(List[i] + ","); + i++; + } + System.out.print(List[Amount - 1]); + } + + public static String AscendingOrder(List[] Amount) //I could not get this to work I tried for a while + { + List[]order; + List.sort(Amount); + order = Amount; + return (List.toString(order)); + } +} \ No newline at end of file diff --git a/dburrigh/src/Temperature.java b/dburrigh/src/Temperature.java new file mode 100644 index 0000000..6c2bfff --- /dev/null +++ b/dburrigh/src/Temperature.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class Temperature { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + double F = scan.nextDouble(); + double result = Convert(F); + System.out.print(result); + } + + private static double Convert(double F) { + double C = (F - 32.0) * (5.0 / 9.0); + return C; + } +} \ No newline at end of file diff --git a/dburrigh/src/Triangle.java b/dburrigh/src/Triangle.java new file mode 100644 index 0000000..69dc590 --- /dev/null +++ b/dburrigh/src/Triangle.java @@ -0,0 +1,35 @@ +import java.util.Scanner; + +public class Triangle { + public static void main(String[] args) + { + Scanner in = new Scanner(System.in); + int Ax = in.nextInt(); //I want to input each x and y separately for each vertex + int Ay = in.nextInt(); + int Bx = in.nextInt(); + int By = in.nextInt(); + int Cx = in.nextInt(); + int Cy = in.nextInt(); + double resultAB = SideAB(Ax,Ay,Bx,By); + double resultAC = SideAC(Ax,Ay,Cx,Cy); + double resultBC = SideBC(Bx,By,Cx,Cy); + System.out.print("For this Triangle, Side AB = " + resultAB + " Side AC = " + resultAC + " Side BC = " + resultBC); + } + private static double SideAB(int Ax, int Ay, int Bx, int By) + { + double LengthAB = Math.sqrt(Math.pow(Bx - Ax,2) + Math.pow(By - Ay,2)); //Math.pow was the only way I knew how to set mathematical expressions to the 2nd power + return LengthAB; + } + + private static double SideAC(int Ax, int Ay, int Cx, int Cy) + { + double LengthAC = Math.sqrt(Math.pow(Cx - Ax,2) + Math.pow(Cy - Ay,2)); + return LengthAC; + } + + private static double SideBC(int Bx, int By, int Cx, int Cy) + { + double LengthBC = Math.sqrt(Math.pow(Cx - Bx,2) + Math.pow(Cy - By,2)); + return LengthBC; + } +} \ No newline at end of file diff --git a/jackhinze/src/changingTemp.java b/jackhinze/src/changingTemp.java new file mode 100644 index 0000000..536c657 --- /dev/null +++ b/jackhinze/src/changingTemp.java @@ -0,0 +1,17 @@ +import java.util.Scanner; + + +public class changingTemp +{ + public static double changeFtoC(int degreesF) + { + return(degreesF-32)*5/9.0; + } + public static void main (String []args) + { + Scanner scan= new Scanner(System.in); + int degreesF= scan.nextInt(); + int F= degreesF; + System.out.println(changeFtoC(F)); + } +} diff --git a/jackhinze/src/recursive.java b/jackhinze/src/recursive.java new file mode 100644 index 0000000..7174c3e --- /dev/null +++ b/jackhinze/src/recursive.java @@ -0,0 +1,25 @@ +import java.util.Scanner; + +public class recursive { + + private static long factorial(int number) + { + long result = 0; + System.out.print(number + " "); + if( number <=1) + return 1; + + result = number* factorial( number - 1); + return result; + } + + public static void main(String[] args) + { + Scanner sysIn = new Scanner(System.in); + int number = sysIn.nextInt(); + long result = factorial(number); + + System.out.println( ); + System.out.println( result ); + } +} diff --git a/jackhinze/src/recursive2 b/jackhinze/src/recursive2 new file mode 100644 index 0000000..55b0221 --- /dev/null +++ b/jackhinze/src/recursive2 @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class recursive2 { + + private static long Cannonballs (int level) + { + long result = 0; + System.out.print(Number of Cannonballs " "); + if( number <=1) + return 1; + + result = level * (level + 1)/2; // In this step, we are receiving the number of cannonballs on the level. + return result; + } + + public static void main(String[] args) + { + Scanner sysIn = new Scanner(System.in); + int level = sysIn.nextInt(); + long result = Cannonballs(level); + + System.out.println( ); + System.out.println( result ); + } +} + diff --git a/jackhinze/src/recursive3 b/jackhinze/src/recursive3 new file mode 100644 index 0000000..b6fddf5 --- /dev/null +++ b/jackhinze/src/recursive3 @@ -0,0 +1,30 @@ +import java.util.Scanner + +public class recursive3 { + +public static void main(String[] args) +{ + +Scanner read = new Scanner(System.in); +String str = read.nextline(); +String reverse = ""; + +for(int i = str.length() - 1; i >= 0; i--) +{ + +reverse = reverse + str.charAt(i); // This is taking the previous function for reversal + +} + +if(forwards.equals(reverse)) // This command checks to see if the word is a palindrome + System.out.println(forwards " is a palindrome"); // If so, the code prints out the word "is a palindrome" + else // Else, not a palindrome + System.out.println(input " is not a palindrome"); // This will print the word "is not a palindrome" + + } +} + + + + +Braly Keller helped me with some of the coding for this problem. diff --git a/jackhinze/src/reverseString.java b/jackhinze/src/reverseString.java new file mode 100644 index 0000000..515e1bc --- /dev/null +++ b/jackhinze/src/reverseString.java @@ -0,0 +1,29 @@ +import java.util.Scanner; + + +class reverseString +{ + + private static String ReverseString(String original) + { + int length = original.length(); + String reverse = ""; + for (int i=length-1; i>=0; i--); + int i=length-1; + reverse = reverse + original.charAt(i); + + return reverse; + + } + public static void main( String [] args) + { + Scanner sysIn = new Scanner(System.in); + String original, reverse= ""; + System.out.println("Enter a string to reverse:"); + original = sysIn.nextLine(); + + reverse=ReverseString(original); + System.out.println(reverse); + } + +} diff --git a/jackhinze/src/sideLengths.java b/jackhinze/src/sideLengths.java new file mode 100644 index 0000000..034ed9c --- /dev/null +++ b/jackhinze/src/sideLengths.java @@ -0,0 +1,7 @@ +import java.util.Scanner; + + +public class sideLengths +{ + +} diff --git a/jackhinze/src/temperature.java b/jackhinze/src/temperature.java new file mode 100644 index 0000000..9545d18 --- /dev/null +++ b/jackhinze/src/temperature.java @@ -0,0 +1,6 @@ +import java.util.Scanner; + +public class temperature +{ + +} diff --git a/jifland/test b/jifland/test new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/jifland/test @@ -0,0 +1 @@ + diff --git a/piiamt/CannonBall b/piiamt/CannonBall new file mode 100644 index 0000000..81760e4 --- /dev/null +++ b/piiamt/CannonBall @@ -0,0 +1,21 @@ +import java.util.Scanner; + +public class CannonBall { + + public static int balls(int initial){ + int what; + if (initial>1){ + what=initial+balls(initial-1); + } + else{ + what=1; + } + return what; + } + + public static void main (String[] args){ + Scanner reader = new Scanner(System.in); + int initial=reader.nextInt(); + System.out.println(balls(initial)); + } +} diff --git a/piiamt/factorial b/piiamt/factorial new file mode 100644 index 0000000..1945693 --- /dev/null +++ b/piiamt/factorial @@ -0,0 +1,21 @@ +import java.util.Scanner; + +public class factorial { + + public static int fact(int initial){ + int k; + if (initial-1>=1){ + k = initial*fact(initial-1); + } + else{ + k=1; + } + return k; + } + public static void main (String[] args){ + Scanner reader = new Scanner(System.in); + int initial=reader.nextInt(); + System.out.println(fact(initial)); + } + +} diff --git a/piiamt/palindrome b/piiamt/palindrome new file mode 100644 index 0000000..5fc7035 --- /dev/null +++ b/piiamt/palindrome @@ -0,0 +1,20 @@ +import java.util.Arrays; +import java.util.Scanner; + +public class palindrome { + + public static String reverse(String wordIn){ + char[] reversed = new char[wordIn.length()]; + for (int i=0; i= 0 ; i-- ) + reverse = reverse + original.charAt(i); + + System.out.println("Reverse of entered string is: "+reverse); + } +} diff --git a/ylopez20/Temperature Problem b/ylopez20/Temperature Problem new file mode 100644 index 0000000..997774d --- /dev/null +++ b/ylopez20/Temperature Problem @@ -0,0 +1,19 @@ +import java.util.Scanner; + +public class labFourTemperature { + + public static void main(String[] args) + { + double celsius, fahrenheit; + + Scanner s = new Scanner(System.in); + + System.out.print("Enter temperature in Fahrenheit:"); + + fahrenheit = s.nextDouble(); + + celsius = (fahrenheit-32)*(0.5556); + + System.out.println("Temperature in Celsius:"+celsius); + } + } diff --git a/ylopez20/Triangle Problem b/ylopez20/Triangle Problem new file mode 100644 index 0000000..e316fbc --- /dev/null +++ b/ylopez20/Triangle Problem @@ -0,0 +1,26 @@ +import java.util.Scanner; + +public class LabFourTriangle { + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + int a = sc.nextInt(); + int b = sc.nextInt(); + int c = sc.nextInt(); + + + if(a==b && b==c) + System.out.println("Equilateral"); + + else if(a >= (b+c) || c >= (b+a) || b >= (a+c) ) + System.out.println("Not a triangle"); + + else if ((a==b && b!=c ) || (a!=b && c==a) || (c==b && c!=a)) + System.out.println("Isosceles"); + + else if(a!=b && b!=c && c!=a) + System.out.println("Scalene"); + } +} +