From bc404ffe18660a6d844640f92effd695af8afc38 Mon Sep 17 00:00:00 2001 From: Scampbell68 Date: Thu, 26 Jul 2018 10:12:48 -0500 Subject: [PATCH 1/8] added method demo --- ch04/HelloMethod.java | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 ch04/HelloMethod.java diff --git a/ch04/HelloMethod.java b/ch04/HelloMethod.java new file mode 100644 index 0000000..a285fcb --- /dev/null +++ b/ch04/HelloMethod.java @@ -0,0 +1,35 @@ +import java.sql.SQLOutput; + +public class HelloMethod +{ + public static void main(String[] args) + { + String firstName = "Fred "; + String secondName = "Wilma "; + String thirdName = "Pebbles"; + String lastName = "Flintstone"; + printHelloWorld(firstName, lastName); + printHelloWorld(secondName, lastName); + printHelloWorld(thirdName, lastName); + printOhNo(); + } + + public static void printHelloWorld(String fname, String lName) + { + System.out.println("Hello World " + fname + lName); + } + + public static void printOhNo() + { + System.out.println("Oh No !!!!!!!!!!"); + + } + + public static void printNumberNoSign(int number) + { + + } + + +} + From 69ae792bb6b16048ad40b1cc4fa9338728c0ab43 Mon Sep 17 00:00:00 2001 From: Scampbell68 Date: Thu, 26 Jul 2018 16:14:10 -0500 Subject: [PATCH 2/8] comparison exercise --- ch05/.idea/vcs.xml | 6 ++++++ ch05/Comparison.java | 25 +++++++++++++++++++++++++ ch05/Logic.java | 10 ++++++++++ 3 files changed, 41 insertions(+) create mode 100644 ch05/.idea/vcs.xml create mode 100644 ch05/Comparison.java create mode 100644 ch05/Logic.java diff --git a/ch05/.idea/vcs.xml b/ch05/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/ch05/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ch05/Comparison.java b/ch05/Comparison.java new file mode 100644 index 0000000..47b93b5 --- /dev/null +++ b/ch05/Comparison.java @@ -0,0 +1,25 @@ +public class Comparison +{ + public static void main(String[] args) + { + String txt="Fantastic"; + String lang="Java"; + + Boolean state = (txt==lang);//Assign test result + System.out.println("String Equality Test: "+state); + + state= (txt !=lang); + System.out.println("string Inequality Test: "+state); + + int dozen =12; + int score =20; + state =(dozen>score); + System.out.println("Greater Than Test: "+state); + + state =(dozen Date: Thu, 26 Jul 2018 16:25:01 -0500 Subject: [PATCH 3/8] comparison exercise --- ch05/Logic.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ch05/Logic.java b/ch05/Logic.java index 4576bce..a04845a 100644 --- a/ch05/Logic.java +++ b/ch05/Logic.java @@ -6,5 +6,12 @@ public static void main(String[] args) boolean no =false; System.out.println("Both YesYes True:"+(yes && yes)); System.out.println("Both YesNot True:" +(yes && no)); + + System.out.println("Either YesYes True: "+(yes||yes)); + System.out.println("Either YesNo True: "+(yes||no)); + System.out.println("Either NoNo True: "+(no||no)); + + System.out.println("Original Yes Value: "+yes); + System.out.println("Inverse Yes Value: "+!yes); } } From 1cf976f79dbbfb63c61998858315970ca84221ea Mon Sep 17 00:00:00 2001 From: Scampbell68 Date: Thu, 26 Jul 2018 16:39:56 -0500 Subject: [PATCH 4/8] condition --- ch05/Condition.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ch05/Condition.java diff --git a/ch05/Condition.java b/ch05/Condition.java new file mode 100644 index 0000000..fdd9203 --- /dev/null +++ b/ch05/Condition.java @@ -0,0 +1,15 @@ +public class Condition +{ + public static void main(String[] args) + { + int num1= 1357; + int num2 = 2468; + String result; + result = (num1%2!=0)?"Odd":"Even"; + System.out.println(num1+" is "+result); + + result = (num2%2!=0)?"Odd":"Even;"; + System.out.println(num2 + " is "+ result); + + } +} From efad04385bc4aaca81e1155ac67a362a3a108f78 Mon Sep 17 00:00:00 2001 From: Scampbell68 Date: Thu, 26 Jul 2018 16:49:21 -0500 Subject: [PATCH 5/8] Precedence --- ch05/Precedence.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 ch05/Precedence.java diff --git a/ch05/Precedence.java b/ch05/Precedence.java new file mode 100644 index 0000000..a67cc97 --- /dev/null +++ b/ch05/Precedence.java @@ -0,0 +1,14 @@ +public class Precedence +{ + public static void main(String[] args) + { + int sum = 32-8+16*2; + System.out.println("Default order: "+sum); + + sum=(32-8+16)*2; + System.out.println("Specified order: "+sum); + + sum=(32-(8+16))*2; + System.out.println("Nested specific order: "+sum); + } +} From 842ebba5b8a0b5725020a3209038184c7e532d91 Mon Sep 17 00:00:00 2001 From: Scampbell68 Date: Fri, 27 Jul 2018 09:39:35 -0500 Subject: [PATCH 6/8] switch --- ch05/Switch.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ch05/Switch.java diff --git a/ch05/Switch.java b/ch05/Switch.java new file mode 100644 index 0000000..c1e8fde --- /dev/null +++ b/ch05/Switch.java @@ -0,0 +1,22 @@ +public class Switch +{ + public static void main(String[] args) + { + int month = 2, year = 2016, num = 31; + switch (month) + { + case 4: + case 6: + case 9: + case 11: + num = 30; + break; + case 2: num = (year%4==0)?29:28; + break; + } + System.out.println(month+"/"+year+":"+num+"days"); + + } + + +} From dcd8ec45f5d36b5c5aa10de2c1d9484846f30983 Mon Sep 17 00:00:00 2001 From: Scampbell68 Date: Sun, 29 Jul 2018 08:18:02 -0500 Subject: [PATCH 7/8] cheesy cheesy --- ch05/CrazyEd.java | 76 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 ch05/CrazyEd.java diff --git a/ch05/CrazyEd.java b/ch05/CrazyEd.java new file mode 100644 index 0000000..61057d2 --- /dev/null +++ b/ch05/CrazyEd.java @@ -0,0 +1,76 @@ +import java.util.Scanner; + +public class CrazyEd +{ + + + public static void main(String[] args) + { + Scanner scanner = new Scanner(System.in); + + System.out.println("What size would you like?"); + int diameter = scanner.nextInt(); + + if (diameter > 3) + System.out.println("This order is crazy and you are stupid. We obviously don't sell that here."); + + System.out.println("How many yards would you like?"); + int length = scanner.nextInt(); + + if (length > 1000) + System.out.println("This order is crazy and you are stupid. There's not that much cheese in Wisconsin."); + System.out.println("Your total delivered cost is:"); + boolean price1 = diameter == 1; + boolean shipping1 = diameter == 1; + boolean price2 = diameter == 2; + boolean shipping2 = diameter == 2; + boolean price3 = diameter == 3; + boolean shipping3 = diameter == 3; + + + { + if (price1 && length <= 50) + System.out.println("$" + (2 * (length) + 2 * (length))); + + if (price1 && length > 50) + System.out.println("$" + (2 * (length))); + + + if (price2 && length <= 50) + System.out.println("$" + (4 * (length) + 2 * (length))); + + if (price2 && length > 50) + System.out.println("$" + (4 * (length))); + + if (price3 && length <= 50) + System.out.println("$" + (6 * (length) + 4 * (length))); + + if (price3 && length > 50) + System.out.println("$" + (6 * (length))); + + + + /* if (price4) + System.out.println("This order is crazy and you are stupid. We obviously don't sell that here."); +*/ + } +/* public static void priceperyard(int price) + { + + + switch (price) + { + case 1: price=2; + + System.out.println("The price of your order is:"+price*length); + case 2: price=3; + case 3: price=6; + + + } +*/ + } + + +} + From d53d768863f37a2523702d68ab26f270285f563f Mon Sep 17 00:00:00 2001 From: Scampbell68 Date: Tue, 31 Jul 2018 10:05:44 -0500 Subject: [PATCH 8/8] oxoxox --- ch06/.idea/vcs.xml | 6 +++++ ch06/Demo.java | 32 +++++++++++++++++++++++++++ ch06/MathUtil.java | 55 ++++++++++++++++++++++++++++++++++++++++++++++ ch06/Names.java | 24 ++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 ch06/.idea/vcs.xml create mode 100644 ch06/Demo.java create mode 100644 ch06/MathUtil.java create mode 100644 ch06/Names.java diff --git a/ch06/.idea/vcs.xml b/ch06/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/ch06/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ch06/Demo.java b/ch06/Demo.java new file mode 100644 index 0000000..c0c9486 --- /dev/null +++ b/ch06/Demo.java @@ -0,0 +1,32 @@ +import java.util.Scanner; + +public class Demo +{ + public static void main(String[] args) + { + printGreeting("HELLO"); + + + Scanner in = new Scanner(System.in); + + System.out.println("Enter a number:"); + + int firstNumber=in.nextInt(); + + System.out.println("Enter a number:"); + + int secondNumber=in.nextInt(); + + int total = firstNumber + secondNumber; + System.out.println("the total is "+total); + } + + public static void printTotal() + { + + } + public static void printGreeting(String greeting) + { + System.out.println("<<<"+ greeting + ">>>"); + } +} diff --git a/ch06/MathUtil.java b/ch06/MathUtil.java new file mode 100644 index 0000000..26e2ae8 --- /dev/null +++ b/ch06/MathUtil.java @@ -0,0 +1,55 @@ +public class MathUtil +{ + public static void main(String[] args) + { + int total = getTotal(1, 2); + + System.out.println(total); + double cargoVolume = getCargoVolume(2, 2, 2, false); + System.out.println(cargoVolume); + + int absoluteAnswer = absoluteSum(-5, 2); + System.out.println(absoluteAnswer); + + int absoluteAnswerTwo = absoluteSum(-5, 2, -3); + System.out.println(absoluteAnswerTwo); + + } + + public static int getTotal(int firstNumber, int secondNumber) + { + int sum = firstNumber + secondNumber; + + return sum; + } + + public static double getCargoVolume(double height, double length, double depth, boolean heavyDuty) + { + + double materialThickness = .25; + if (heavyDuty) ; + materialThickness = .25 * 2; + double interiorHeight = height - (2 * materialThickness); + double interiorLength = length - (2 * materialThickness); + double interiorDepth = depth - (2 * materialThickness); + double cargoVolume = interiorHeight * interiorLength * interiorDepth; + return cargoVolume; + } + + public static int absoluteSum(int numberone, int numberTwo) + { + int absoluteOne = Math.abs(numberone); + int absoluteTwo = Math.abs(numberTwo); + int absoluteAnswer = absoluteOne + absoluteTwo; + return absoluteAnswer; + } + + public static int absoluteSum(int numberone, int numberTwo, int numberThree) + { + int absoluteOne = Math.abs(numberone); + int absoluteTwo = Math.abs(numberTwo); + int absoluteThree = Math.abs(numberThree); + int absoluteAnswerTwo = absoluteOne + absoluteTwo + absoluteThree; + return absoluteAnswerTwo; + } +} diff --git a/ch06/Names.java b/ch06/Names.java new file mode 100644 index 0000000..ad8d04c --- /dev/null +++ b/ch06/Names.java @@ -0,0 +1,24 @@ +public class Names +{ + public static void main(String[] args) + { + //String decoration=%%%%%%%; + String returnValue=getMyName(); + + String fancyName=getMyFancyName("%%%%%%%%"); + + System.out.println(returnValue); + System.out.println(fancyName); + } + + public static String getMyName( ) + + { + return "Stephen"; + } + public static String getMyFancyName(String decoration) + { + String fancyName = decoration +"Stephen"+decoration; + return fancyName; + } +}