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.

9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,17 @@ 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.
### Part 2 - Answers
1) String variables that have characters as data type.
2) Integer variables with numeric data type
3) Boolean variable with integer and characters
4) Scanner variable with characters

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 examples
* Integer varaiable assigned the words hello because integer variable must have an integer not a character
* double precision floating point variable assigned characters because dEmotionalDamage = must have a integer value
### 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
14 changes: 7 additions & 7 deletions src/LikeAGirl.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ 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 ansGood = "Good for you.%nEmotional Damage %f";
String ansBad = "Always wants to change that.%nEmotional Damage %f";
String likeAGirl = "Like a Girl";

// 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 = 100.0f; // 32 Bit, but it does exist!
// double precision floating point variable
double dEmotionalDamage = 100.0; // Double precision
double dEmotionalDamage = 50.0f; // Double precision
// boolean variable
boolean trueOrFalse;
// Scanner variable for reading input.
Expand All @@ -49,7 +49,7 @@ public static void main(String[] args) {
)
);

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);
}
}