Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,19 @@ 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.

Next give TWO example variable names and TWO example variable assignments that are **WRONG** and explain why.
**A few variable types found in LikeAGirl.java**
* scriptTemplateLine1 is a String (non-primitive), the types of values you can assign to a string are a string of characters
* good is an int or integer (primitive) and can be assigned a value of single digit integer such as 1
* emotionalDamage is a float (primitive) and can be assigned a value of a digit with a decimal point but must include a "f" after the number
* dEmotionalDamage is a double (primitive) and can be assigned a value of digit with a decimal point
* trueOrFalse is a boolean (primitive) and can have a value of true or false


* Next give TWO example variable names and TWO example variable assignments that are **WRONG** and explain why.

1. **int 1dayOfYear = 365.0; is wrong because you can not start a name with a number and the value has a decimal and is either a float or a double**
2. **boolean isItTrue! = yes; is wrong because you can not use an explanation mark in a name and a boolean data type can only produce a value of true or false**

* Hint: your IDE can help you discover wrong assignments or variable names!

### Part 3 - Bonus: Play around with Java String Format Specifiers.
Expand Down
34 changes: 28 additions & 6 deletions src/LikeAGirl.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import java.util.Scanner;

/**
* @author Trevor Hartman
* @author MJ Fracess
*
* @since Version 1.0
*/
public class LikeAGirl {
/**
* "Like a Girl," Super Bowl XLIX (2015) - <a href="https://www.youtube.com/watch?v=5yLXrWLvwAo">Like a Girl</a>
Expand All @@ -15,17 +21,23 @@ 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"; //changed from "Like a Girl"
String bonusAttempt = "Do you like bonus points? \"%s\"!";
String bonusSecondAttempt = "Do you like good grades, \"%s\"!";
String whatDoYouLike = "You know it";
String Question = "Are you sure?";


// 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! Changed from original value of 0.0f
// 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);

Expand All @@ -44,12 +56,22 @@ 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 == 2 (i.e. bad), then trueOrFalse should be False
System.out.printf("Did you answer like a nice person? %B%n", trueOrFalse);
System.out.println(
String.format(bonusAttempt, whatDoYouLike));
System.out.println(
String.format(bonusSecondAttempt, whatDoYouLike));
System.out.println(Question);
System.out.print(dEmotionalDamage);




}
}