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
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ Review the flow of execution through the program [Zippo.java](src/Zippo.java), a
**Questions to Answer In This README.md:**
1. Write the number 1 next to the first line of code in this program that will execute.
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?
3. What is the value of the parameter `blimp` when `baffle` gets invoked? *rattle*
4. What is the output of this program?
ik
rattle
ping zoop
boo-wa-ha-ha

---

Expand All @@ -43,6 +47,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
ik
ping zoop
boo-wa-ha-ha

```

Expand All @@ -56,9 +63,9 @@ Explore method invocations and their consequences.
**Questions to answer in the README.md via Markdown:**
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;`.

The method will execute but the returned value is discarded.
---

You'll receive a compilation error
## Part 5: Stack Diagram and Program Output

**Objective:**
Expand All @@ -71,8 +78,21 @@ 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
| |
| main() |
|_________________|
| |
| zoop() |
|_________________|
| |
| ping() |
|_________________|


```
just for
any not more
It's breakfast !

## Submission
Follow these steps for submission:
Expand Down
25 changes: 25 additions & 0 deletions src/RedesignDate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import java.util.*;

public class RedesignDate {
public static void printAmerican(int day, int date, int month, int year) {
String[] daysOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
String[] monthsOfYear = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

String dayOfWeek = daysOfWeek[new GregorianCalendar(year, month - 1, date).get(Calendar.DAY_OF_WEEK) - 1];
String monthOfYear = monthsOfYear[month - 1];

System.out.println(dayOfWeek + ", " + monthOfYear + " " + date + ", " + year);
}

public static void printEuropean(int day, int date, int month, int year) {
System.out.println(date + " " + month + ", " + year);
}

public static void main(String[] args) {

printAmerican(2, 10, 2, 2024); // Example invocation


printEuropean(2, 10, 2, 2024); // Example invocation
}
}
6 changes: 3 additions & 3 deletions src/Zippo.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
public class Zippo {
public static void baffle(String blimp) {
System.out.println(blimp);
System.out.println(blimp);3
zippo("ping", -5);
}
public static void zippo(String quince, int flag) {
if (flag < 0) {
if (flag < 0) {2
System.out.println(quince + " zoop");
} else {
System.out.println("ik");
Expand All @@ -15,5 +15,5 @@ public static void zippo(String quince, int flag) {

public static void main(String[] args) {
zippo("rattle", 13);
}
}1
}