From 060b7ae1390a27e32ffe7a185ca5e393005e7f69 Mon Sep 17 00:00:00 2001 From: lance Date: Thu, 31 Aug 2023 12:19:21 -0700 Subject: [PATCH] Completion of Java-Lab-002 --- .idea/misc.xml | 1 - README.md | 8 ++++++++ src/LikeAGirl.java | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 03f397c..ca950ab 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/README.md b/README.md index b866789..0fc8496 100644 --- a/README.md +++ b/README.md @@ -59,8 +59,16 @@ 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. +### Student - Answer - Summary +1. emotional damage, a float, 32 bit number. I can change it from 0 to 50 and change the emotional damage I receive. +2. ansBad, String, It tells me "Good for you." Then states %nEmotional Damage %f of ansBad. + 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! +### Student - Answer - Summary +1. int Main and int System are keywords that can't be used for Variables +2. A. int good = 2.20 doesn't work. an integer does not hold rational numbers. +B. double emotionalDamage = 50000...(more than 64). double is limited to 64 bits. For numbers bigger than 64 integers you would was to use BigInteger ### Part 3 - Bonus: Play around with Java String Format Specifiers. diff --git a/src/LikeAGirl.java b/src/LikeAGirl.java index 30b943b..e5568d5 100644 --- a/src/LikeAGirl.java +++ b/src/LikeAGirl.java @@ -15,13 +15,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 good = 2; int bad = 1; // 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