diff --git a/.idea/misc.xml b/.idea/misc.xml index cf9abe6..cbbff6a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/Part5StateOfProgramScreenShot.png b/Part5StateOfProgramScreenShot.png new file mode 100644 index 0000000..be53c28 Binary files /dev/null and b/Part5StateOfProgramScreenShot.png differ diff --git a/README.md b/README.md index 40c2bd8..8c425fd 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,19 @@ Review the flow of execution through the program [Zippo.java](src/Zippo.java), a 2. Write the number 2 next to the second line of code, and so on until the end of the program. 3. What is the value of the parameter `blimp` when `baffle` gets invoked? 4. What is the output of this program? - +--- +**Answers to Part 2** + +1. zippo("rattle", 13); is the first line of code to execute +2. if (flag < 0) is the second line of code to execute and the following lines are all marked via comments on the actual code. +3. The value of parameter blimp is rattle when baffle gets invoked. +4. The output is +``` Bash +ik +rattle +ping zoop +boo-wa-ha-ha +``` --- ## Part 3: Stack Diagram and Program Output @@ -43,7 +55,9 @@ Answer questions about stack diagrams and program output without running the pro 2. What is the output by the following program? * Paste your output in the bash code-block below. ```bash - +No, I wug. +You wugga wug. +I wug. ``` --- @@ -57,6 +71,10 @@ Explore method invocations and their consequences. 1. What happens if you invoke a value method and don’t do anything with the result; that is, if you don’t assign it to a variable or use it as part of a larger expression? 2. What happens if you use a void method as part of an expression? For example, try `System.out.println("boo!") + 7;`. +--- +**Answers to Part 4** +1. Invoking a value method without doing anything with the result leads to that method still executing but nothing being done with the value it returns. +2. The program tells you there is an error because the operator cannot be applied to that void method. --- ## Part 5: Stack Diagram and Program Output @@ -71,7 +89,10 @@ Draw a stack diagram that shows the state of the program the second time `zoop` 2. What is the complete output? * Paste your output in the bash code-block below. ```bash - +just for +any not more +It's breakfast +! ``` ## Submission diff --git a/ZoopStateOfProgramScreenShot.png b/ZoopStateOfProgramScreenShot.png new file mode 100644 index 0000000..b4a416c Binary files /dev/null and b/ZoopStateOfProgramScreenShot.png differ diff --git a/src/RedesignDate.java b/src/RedesignDate.java new file mode 100644 index 0000000..cf46ff1 --- /dev/null +++ b/src/RedesignDate.java @@ -0,0 +1,32 @@ +/** + * + * @author Trevor Hartman + * @author Eliot Rodriguez + * + * @since version 1.0 + * February 6, 2024 + * + */ +public class RedesignDate{ +public static void printAmerican(String day, int date, String month, int year) { + System.out.print(day+", "); + System.out.print(month + " "); + System.out.print(date+", "); + System.out.print(year); +} +public static void printEuropean(String day, int date, String month, int year) { + System.out.println(); + System.out.print(day+", "); + System.out.print(date + " "); + System.out.print(month+", "); + System.out.print(year); +} + public static void main(String[] args) { + String day = "Tuesday"; + String month = "February"; + int date = 6; + int year = 2024; + printAmerican(day,date,month,year); + printEuropean(day,date,month,year); + } +} diff --git a/src/Zippo.java b/src/Zippo.java index 04581a4..bccf5d7 100644 --- a/src/Zippo.java +++ b/src/Zippo.java @@ -1,19 +1,19 @@ public class Zippo { public static void baffle(String blimp) { - System.out.println(blimp); - zippo("ping", -5); + System.out.println(blimp); //5 + zippo("ping", -5); //6 } public static void zippo(String quince, int flag) { - if (flag < 0) { - System.out.println(quince + " zoop"); + if (flag < 0) { //2 //7 + System.out.println(quince + " zoop"); //8 } else { - System.out.println("ik"); - baffle(quince); - System.out.println("boo-wa-ha-ha"); + System.out.println("ik"); //3 + baffle(quince); //4 + System.out.println("boo-wa-ha-ha"); //9 } } public static void main(String[] args) { zippo("rattle", 13); - } + } //1 }