From 9552c403e73a206ca721dae234ee801d7a82f031 Mon Sep 17 00:00:00 2001 From: tchristie119 Date: Sat, 2 Sep 2023 20:52:11 -0700 Subject: [PATCH] tc Commit --- .idea/misc.xml | 2 +- README.md | 15 +++++++++++---- src/LikeAGirl.java | 21 +++++++++++++++------ 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 03f397c..cf9abe6 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/README.md b/README.md index b866789..c654891 100644 --- a/README.md +++ b/README.md @@ -55,12 +55,19 @@ 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: dEmotionalDamage +* Data Type: double +* Example Values: 100.0 , 50.0 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! + +Names +* int **1test** = 123 - names can't start with numbers +* double **test!** = 123.0 - no special characters + +Assignments +* char test = **123** - char can only represent characters, not numbers +* int test2 = **123.0** - floating point variables should be typed as float or double, not int ### Part 3 - Bonus: Play around with Java String Format Specifiers. diff --git a/src/LikeAGirl.java b/src/LikeAGirl.java index 30b943b..a0fd740 100644 --- a/src/LikeAGirl.java +++ b/src/LikeAGirl.java @@ -1,3 +1,12 @@ +/** + * + * @author Trevor Hartman + * @author Taylor Christie + * + * @since Version 1.0 + * + */ + import java.util.Scanner; public class LikeAGirl { @@ -15,13 +24,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 @@ -44,12 +53,12 @@ public static void main(String[] args) { System.out.println( String.format(scriptTemplateLine5, answer, - (answer == good) ? + (answer == bad) ? String.format(ansGood, dEmotionalDamage) : String.format(ansBad, emotionalDamage) ) ); - 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); } }