Skip to content

Exercise 2 (data types) #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class WhenWorkingWithFloatingPointNumbers {
@Test
public void convertToFarenheit() {
double celcius = 27.0d;
double farenheit = 0.0d;
double farenheit = (9.0/5.0) * celcius + 32.0;

// TODO: Use a floating point calculation to calculate the farenheit equivalent of the celcius value.

Expand All @@ -28,7 +28,7 @@ public void convertToFarenheit() {
@Test
public void convertMetersToFeet() {
int weightInKilograms = 50;
double weightInPounds = 0;
double weightInPounds = weightInKilograms * 2.20462;

// TODO: Use a floating point calculation to calculate the correct weight in pounds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class WhenWorkingWithStrings {
public void convertToLowerCase() {
String bookTitle = "The Cat In The Hat";

String lowerCaseTitle = "";
String lowerCaseTitle = bookTitle.toLowerCase();
// TODO: Convert the book title to lower case and assign it to the lowerCaseTitle variable

assertThat(lowerCaseTitle, equalTo("the cat in the hat"));
Expand All @@ -22,7 +22,7 @@ public void convertToLowerCase() {
public void convertToUpperCase() {
String bookTitle = "The Cat In The Hat";

String upperCaseTitle = "";
String upperCaseTitle = bookTitle.toUpperCase();
// TODO: Convert the book title to upper case and assign it to the lowerCaseTitle variable

assertThat(upperCaseTitle, equalTo("THE CAT IN THE HAT"));
Expand All @@ -32,7 +32,7 @@ public void convertToUpperCase() {
public void trimExtraSpaces() {
String bookTitle = " The Cat In The Hat ";

String trimmedTitle = "";
String trimmedTitle = bookTitle.trim();
// TODO: Trim the spaces before and after the title text

assertThat(trimmedTitle, equalTo("The Cat In The Hat"));
Expand All @@ -42,7 +42,7 @@ public void trimExtraSpaces() {
public void findTheLengthOfAString() {
String bookTitle = "The Cat In The Hat";

int length = 0;
int length = bookTitle.length();
// TODO: Find the number of characters in the string

assertThat(length, equalTo(18));
Expand All @@ -52,7 +52,7 @@ public void findTheLengthOfAString() {
public void replacingAText() {
String bookTitle = "The Cat In The Hat";

String updatedTitle = "";
String updatedTitle = bookTitle.replace("Cat", "Dog");
// TODO: Replace the word "Cat" with "Dog

assertThat(updatedTitle, equalTo("The Dog In The Hat"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class WhenWorkingWithWholeNumbers {
public void addingNumbersTogether() {
int initialYear = 1985;
int targetYear = 0;
int timeJump = 30;
targetYear = initialYear + timeJump;

// TODO: create a new int variable called timeJump and assign it a value
// Next, add this variable to initialYear and assign the result to targetYear, so that targetYear is equal to 2015
Expand Down