From c08e1d7befc3f4e290adaebb7c53c02a6ba6c9f5 Mon Sep 17 00:00:00 2001 From: agarcia923 Date: Thu, 14 Sep 2023 12:37:11 -0700 Subject: [PATCH 1/2] Finally finished Lab-2! --- .idea/misc.xml | 2 +- README.md | 7 +++ src/LikeAGirl.java | 107 +++++++++++++++++++++++---------------------- 3 files changed, 62 insertions(+), 54 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 03f397c..952b1db 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..8702b83 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,10 @@ Pick several of the Java format specifiers below and define variables of the cor * Push it to your Remote/origin branch (i.e. GitHub: Feature1 -> origin/Feature1) * Then issue a Pull request to my instructor branch * Make sure to **COPY** the Pull request URL and submit it for the lab/assignment. + +# Summary + The variable name would be the String scriptTemplateLines and the values can be, "What does it mean to do something, "Like a Girl"?". +or any other stings it states. The data type would be strings which is a sequence of characters. +I think the "You answered 1" has the true or false variable. It gives the data type boolean and creates the value +"Good for you." or "Always wants to change that." depending on the input. + diff --git a/src/LikeAGirl.java b/src/LikeAGirl.java index 30b943b..669f92c 100644 --- a/src/LikeAGirl.java +++ b/src/LikeAGirl.java @@ -1,55 +1,56 @@ import java.util.Scanner; -public class LikeAGirl { - /** - * "Like a Girl," Super Bowl XLIX (2015) - Like a Girl - * @param args Command line arguments [The source file path, The target file path, ...] - **/ - public static void main(String[] args) { - // String variables, some with format specifiers - 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 = - "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 likeAGirl = "Like a Girl"; - - // integer variable - int good = 0; - int bad = 1; - // 32 bit floating point variable - float emotionalDamage = 0.0f; // 32 Bit, but it does exist! - // double precision floating point variable - double dEmotionalDamage = 100.0; // Double precision - // boolean variable - boolean trueOrFalse; - // Scanner variable for reading input. - Scanner s = new Scanner(System.in); - - System.out.println( - String.format(scriptTemplateLine1, likeAGirl)); - - // Example of using printf and platform specific line separator "%n" to - // format instead of String.format - System.out.printf(scriptTemplateLine2, likeAGirl); - - System.out.println(String.format(scriptTemplateLine3, likeAGirl)); - - System.out.printf(scriptTemplateLine4, likeAGirl, good, bad); - - int answer = Integer.parseInt(s.nextLine()); - - System.out.println( - String.format(scriptTemplateLine5, answer, - (answer == good) ? - String.format(ansGood, dEmotionalDamage) : String.format(ansBad, emotionalDamage) - ) - ); - - trueOrFalse = (answer != good); // if answer == 1 (i.e. good), then trueOrFalse should be False - System.out.printf("Did you answer like a nice person? %B%n", trueOrFalse); - } -} + public class LikeAGirl { + /** + * "Like a Girl," Super Bowl XLIX (2015) - Like a Girl + * + * @param args Command line arguments [The source file path, The target file path, ...] + **/ + public static void main(String[] args) { + // String variables, some with format specifiers + 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 = "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 likeAGirl = "Like a Boy"; + + // integer variable + int bad = 1; + int good = 2; + // 32 bit floating point variable + float emotionalDamage = 0.0f; // 32 Bit, but it does exist! + // double precision floating point variable + double dEmotionalDamage = 50.0; // Double precision + // boolean variable + boolean trueOrFalse; + // Scanner variable for reading input. + Scanner s = new Scanner(System.in); + + System.out.println( + String.format(scriptTemplateLine1, likeAGirl)); + + // Example of using printf and platform specific line separator "%n" to + // format instead of String.format + System.out.printf(scriptTemplateLine2, likeAGirl); + + System.out.println(String.format(scriptTemplateLine3, likeAGirl)); + + System.out.printf(scriptTemplateLine4, likeAGirl, good, bad); + + int answer = Integer.parseInt(s.nextLine()); + + System.out.println( + String.format(scriptTemplateLine5, answer, + (answer == good) ? + String.format(ansGood, dEmotionalDamage) : String.format(ansBad, emotionalDamage) + ) + ); + + trueOrFalse = (answer != good); // if answer == 1 (i.e. good), then trueOrFalse should be False + System.out.printf("Did you answer like a nice person? %B%n", trueOrFalse); + System.out.println(String.format(scriptTemplateLine4, likeAGirl, 1, 2)); + } + } \ No newline at end of file From ff84aec3eef5e776850b4bfc9a483c8e348e2374 Mon Sep 17 00:00:00 2001 From: agarcia923 Date: Thu, 14 Sep 2023 12:37:11 -0700 Subject: [PATCH 2/2] Finally finished Lab-2! --- .idea/misc.xml | 2 +- README.md | 9 ++++ src/LikeAGirl.java | 107 +++++++++++++++++++++++---------------------- 3 files changed, 64 insertions(+), 54 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 03f397c..952b1db 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..483d805 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,12 @@ Pick several of the Java format specifiers below and define variables of the cor * Push it to your Remote/origin branch (i.e. GitHub: Feature1 -> origin/Feature1) * Then issue a Pull request to my instructor branch * Make sure to **COPY** the Pull request URL and submit it for the lab/assignment. + +# Summary + The variable name would be the String scriptTemplateLines and the values can be, "What does it mean to do something, "Like a Girl"?". +or any other stings it states. The data type would be strings which is a sequence of characters. +I think the "You answered 1" has the true or false variable. It gives the data type boolean and creates the value +"Good for you." or "Always wants to change that." depending on the input. I'm sort of getting it. +Hey + + diff --git a/src/LikeAGirl.java b/src/LikeAGirl.java index 30b943b..669f92c 100644 --- a/src/LikeAGirl.java +++ b/src/LikeAGirl.java @@ -1,55 +1,56 @@ import java.util.Scanner; -public class LikeAGirl { - /** - * "Like a Girl," Super Bowl XLIX (2015) - Like a Girl - * @param args Command line arguments [The source file path, The target file path, ...] - **/ - public static void main(String[] args) { - // String variables, some with format specifiers - 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 = - "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 likeAGirl = "Like a Girl"; - - // integer variable - int good = 0; - int bad = 1; - // 32 bit floating point variable - float emotionalDamage = 0.0f; // 32 Bit, but it does exist! - // double precision floating point variable - double dEmotionalDamage = 100.0; // Double precision - // boolean variable - boolean trueOrFalse; - // Scanner variable for reading input. - Scanner s = new Scanner(System.in); - - System.out.println( - String.format(scriptTemplateLine1, likeAGirl)); - - // Example of using printf and platform specific line separator "%n" to - // format instead of String.format - System.out.printf(scriptTemplateLine2, likeAGirl); - - System.out.println(String.format(scriptTemplateLine3, likeAGirl)); - - System.out.printf(scriptTemplateLine4, likeAGirl, good, bad); - - int answer = Integer.parseInt(s.nextLine()); - - System.out.println( - String.format(scriptTemplateLine5, answer, - (answer == good) ? - String.format(ansGood, dEmotionalDamage) : String.format(ansBad, emotionalDamage) - ) - ); - - trueOrFalse = (answer != good); // if answer == 1 (i.e. good), then trueOrFalse should be False - System.out.printf("Did you answer like a nice person? %B%n", trueOrFalse); - } -} + public class LikeAGirl { + /** + * "Like a Girl," Super Bowl XLIX (2015) - Like a Girl + * + * @param args Command line arguments [The source file path, The target file path, ...] + **/ + public static void main(String[] args) { + // String variables, some with format specifiers + 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 = "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 likeAGirl = "Like a Boy"; + + // integer variable + int bad = 1; + int good = 2; + // 32 bit floating point variable + float emotionalDamage = 0.0f; // 32 Bit, but it does exist! + // double precision floating point variable + double dEmotionalDamage = 50.0; // Double precision + // boolean variable + boolean trueOrFalse; + // Scanner variable for reading input. + Scanner s = new Scanner(System.in); + + System.out.println( + String.format(scriptTemplateLine1, likeAGirl)); + + // Example of using printf and platform specific line separator "%n" to + // format instead of String.format + System.out.printf(scriptTemplateLine2, likeAGirl); + + System.out.println(String.format(scriptTemplateLine3, likeAGirl)); + + System.out.printf(scriptTemplateLine4, likeAGirl, good, bad); + + int answer = Integer.parseInt(s.nextLine()); + + System.out.println( + String.format(scriptTemplateLine5, answer, + (answer == good) ? + String.format(ansGood, dEmotionalDamage) : String.format(ansBad, emotionalDamage) + ) + ); + + trueOrFalse = (answer != good); // if answer == 1 (i.e. good), then trueOrFalse should be False + System.out.printf("Did you answer like a nice person? %B%n", trueOrFalse); + System.out.println(String.format(scriptTemplateLine4, likeAGirl, 1, 2)); + } + } \ No newline at end of file