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
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The lab template contains a program that prints the following if you choose "0":
What does it mean to do something, "Like a Girl"?
Show me what it looks like to run, "Like a Girl."
Show me what it looks like to fight, "Like a Girl."
How do you think it affects them when somebody uses "Like a Girl" as an insult? Choice (good: 0, bad: 1) 0
How do you think it affects them when somebody uses "Like a Girl" as an insult? Choice (good: 0, bad: 1) 0
You answered 0
Always wants to change that.
Emotional Damage 100.000000.
Expand Down Expand Up @@ -58,10 +58,15 @@ Take note of the various variables and their data types. Write a brief summary i
* Variable name
* Its data type
* and example values you can assign them.

* A variable is a named location that stores
a value. Values may be numbers, text, images, sounds, and other types of
data. Some variable examples are like int and char. These are called primitive data. Int could be int x;
char can be different characters.

Next give TWO example variable names and TWO example variable assignments that are **WRONG** and explain why.
* 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!

Two variable names could be public or class. a type of variabe assignment that wouldnt work would be 123 instead of "123";
### 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.
Expand Down
16 changes: 8 additions & 8 deletions src/LikeAGirl.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public static void main(String[] args) {
String scriptTemplateLine4 =
"How do you think it affects them when somebody uses \"%s\" as an insult? Choice (good: %d, bad: %d) ";
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 ansBad = "Always wants to change that.%nEmotional Damage %f";
String ansGood = "Good for you.%nEmotional Damage %f";
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 @@ -45,11 +45,11 @@ public static void main(String[] args) {
System.out.println(
String.format(scriptTemplateLine5, answer,
(answer == good) ?
String.format(ansGood, dEmotionalDamage) : String.format(ansBad, emotionalDamage)
String.format(ansGood, emotionalDamage) : String.format(ansBad, dEmotionalDamage)
)
);

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