diff --git a/.idea/misc.xml b/.idea/misc.xml index 03f397c..5d30da4 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..27957d3 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,11 @@ Take note of the various variables and their data types. Write a brief summary i 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! +one example of a variable would be a variable made for someones age. The data type would be int, with the name being age, andd the values you could assign could be anything from 0-110. + +two examples: +a variable called public would not work because its a keyword. Samething with class or void. another example would be a string or any variable with its first letter being a capital +wrong assignments would be - int age = 5.5; this is wrong because you would need to use double for something with a decimal. or int time = 12:45; it would be better to use a string for time ### 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..90d75f4 100644 --- a/src/LikeAGirl.java +++ b/src/LikeAGirl.java @@ -7,7 +7,7 @@ public class LikeAGirl { **/ public static void main(String[] args) { // String variables, some with format specifiers - String scriptTemplateLine1 = "What does it mean to do something, \"%s\"?"; + String scriptTemplateLine1 = "What does it mean to do something,\"%s\"?"; String scriptTemplateLine2 = "Show me what it looks like to run, \"%s.\"%n"; String scriptTemplateLine3 = "Show me what it looks like to fight, \"%s.\""; String scriptTemplateLine4 = @@ -15,15 +15,15 @@ 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.000000f; // 32 Bit, but it does exist! // double precision floating point variable - double dEmotionalDamage = 100.0; // Double precision + double dEmotionalDamage = 100.000000; // Double precision // boolean variable boolean trueOrFalse; // Scanner variable for reading input. @@ -44,12 +44,12 @@ public static void main(String[] args) { System.out.println( String.format(scriptTemplateLine5, answer, - (answer == good) ? + (answer != good) ? 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); } }