From 5c92e0942d3547c877a1276dcc20b1e306374bc6 Mon Sep 17 00:00:00 2001 From: Nyrijah Date: Wed, 20 Sep 2023 13:57:36 -0700 Subject: [PATCH] made it work --- README.md | 8 ++++---- src/LikeAGirl.java | 16 ++++++++-------- src/image.java | 3 +++ 3 files changed, 15 insertions(+), 12 deletions(-) create mode 100644 src/image.java diff --git a/README.md b/README.md index b866789..0863829 100644 --- a/README.md +++ b/README.md @@ -55,13 +55,13 @@ Did you answer like a nice person? FALSE ### Part 2 - Interpretation Take note of the various variables and their data types. Write a brief summary in this section of the README.md file listing the: -* Variable name -* Its data type -* and example values you can assign them. +* Variable name - different variable names include good/bad for integer values. s for a scanner. the answer whether its good or bad. +* Its data type - good/bad boolean values either yes 1 or no 2. floating poing +* and example values you can assign them. you can assign 1 to the answer variable to get a response. 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! - +wrong: Bob = dylan, 2Bob = dylan right: bob = dylan bob2 = dylan ### 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. diff --git a/src/LikeAGirl.java b/src/LikeAGirl.java index 30b943b..a9ce670 100644 --- a/src/LikeAGirl.java +++ b/src/LikeAGirl.java @@ -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 ansBad = "Always wants to change that.%nEmotional Damage %f"; + String ansGood = "Good for you.%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 = 50.0f; // 32 Bit, but it does exist! // double precision floating point variable double dEmotionalDamage = 100.0; // Double precision // boolean variable @@ -40,16 +40,16 @@ public static void main(String[] args) { System.out.printf(scriptTemplateLine4, likeAGirl, good, bad); - int answer = Integer.parseInt(s.nextLine()); + int answer = Integer.parseInt(s.nextLine()); 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); } } diff --git a/src/image.java b/src/image.java new file mode 100644 index 0000000..c21470a --- /dev/null +++ b/src/image.java @@ -0,0 +1,3 @@ +public class image { + +}