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.

30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,45 @@ Take note of the various variables and their data types. Write a brief summary i
* Its data type
* and example values you can assign them.

- String scriptTemplateLine1-5 // Strings of characters which provides templates where strings, digits, newlines, and floats are inserted
- int good/bad // Integers which are expected inputs for user response like 1 and 2
- float emotionalDamage / double dEmotionalDamage // Used to display floating point numbers like 50.0
- boolean trueOrFalse // Boolean assigns a true or false statement depending on input

Next give TWO example variable names and TWO example variable assignments that are **WRONG** and explain why.
* Hint: your IDE can help you discover wrong assignments or variable names!

- int number = "5"; // expected integer returned String
- String = 5; // expected string returned integer

### Part 3 - Bonus: Play around with Java String Format Specifiers.

Pick several of the Java format specifiers below and define variables of the correct type utilize **sout** and **String.format** to view the resulting formats.

![Format Specifiers](JavaStringFormatSpecifiers.png)

**Some format specifiers described**

- %b // *Boolean format specifier*
- %s // *String format specifier*
- %f // *Float format specifier*
- %d // *Digit or int format specifier*

**Listed below is an example snippet of code showcasing these format specifiers**

```java
class FormatSpecifiers {
public static void main(String[] args) {
boolean x = true;
boolean x1 = false;
double y = 5.0;
int y1 = 5;
String z = "Lorem ipsum dolor sit amet";
System.out.printf("Booleans can be \"%b\" or \"%b\"\nDoubles have a decimal, like %.1f, while Integers such as %d do not.\nStrings, on the other hand, can be just about any assortment of characters you want, shown here: %s.", x, x1, y, y1, z);
}
}
```

### Part 4 - Submission
* Just as you did last week (Reference the Lab video in your Week 1 module), create a Feature1 branch of your code
* Commit your working code to your local copy
Expand Down
15 changes: 9 additions & 6 deletions src/LikeAGirl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import java.util.Scanner;

/**
* @author Trevor Hartman, Skyler Means
*/
public class LikeAGirl {
/**
* "Like a Girl," Super Bowl XLIX (2015) - <a href="https://www.youtube.com/watch?v=5yLXrWLvwAo">Like a Girl</a>
Expand All @@ -15,13 +18,13 @@ public static void main(String[] args) {
String scriptTemplateLine5 = "You answered %d%n%s.";
String ansGood = "Always wants to change that.%nEmotional Damage %f";
String ansBad = "Good for you.%nEmotional Damage %f";
String likeAGirl = "Like a Girl";
String likeAGirl = "Like a Boy";

// integer variable
int good = 0;
int bad = 1;
int good = 1;
int bad = 2;
// 32 bit floating point variable
float emotionalDamage = 0.0f; // 32 Bit, but it does exist!
float emotionalDamage = 50.0f; // 32 Bit, but it does exist!
// double precision floating point variable
double dEmotionalDamage = 100.0; // Double precision
// boolean variable
Expand All @@ -44,12 +47,12 @@ public static void main(String[] args) {

System.out.println(
String.format(scriptTemplateLine5, answer,
(answer == good) ?
(answer != good) ?
String.format(ansGood, dEmotionalDamage) : String.format(ansBad, emotionalDamage)
)
);

trueOrFalse = (answer != good); // if answer == 1 (i.e. good), then trueOrFalse should be False
trueOrFalse = (answer == good); // if answer == 1 (i.e. good), then trueOrFalse should be False
System.out.printf("Did you answer like a nice person? %B%n", trueOrFalse);
}
}