Sprint Challenge - BD Unit 1 Sprint 1

Overview

Sprint challenges are a way for you to demonstrate that you have mastered the skills you learned this week. The sprint challenge will test you on each of the week's objectives. If you want to spend some more time preparing for the sprint challenge this week, below you will find a list of notes and challenges to give you more practice with the objectives we have covered.

What to Expect in the Sprint Challenge

The Sprint Challenge will assess your understanding of the key concepts covered in this unit's modules:

  • Command-line and IDE Basics
  • Git Basics
  • Variables, Console Output, and Arithmetic Operations
  • Strings, User Input, and Comments

The challenge will involve practical coding tasks that require you to apply these concepts to solve real problems. You'll need to demonstrate your ability to write, test, and debug Java code using the tools and techniques covered in the modules.

Tips for Success

  • Review all module content, guided projects, and code-alongs
  • Practice the key concepts, especially those you found challenging
  • Make sure you understand the underlying principles, not just memorizing syntax
  • Get comfortable with the development environment and workflow
  • Don't hesitate to ask for help if you're stuck on a concept

Setup & Resources

GitHub Repository

Additional Resources

Study Guide

Command-line and IDE Basics

  • Navigate a command-line shell using basic commands (pwd, ls, cd, clear)
  • Create, move, and delete files and directories (mkdir, touch, mv, rm)
  • Understand and use absolute vs. relative paths
  • Set up and configure IntelliJ IDEA
  • Create and run Java projects in IntelliJ
  • Use keyboard shortcuts to improve productivity

Git Basics

  • Initialize a Git repository
  • Clone a remote repository
  • Stage and commit changes
  • Push changes to a remote repository
  • Pull changes from a remote repository
  • Understand basic branching concepts

Variables and Arithmetic Operations

  • Declare and initialize variables of various primitive types
  • Understand Java's primitive data types and their limitations
  • Perform arithmetic operations (+, -, *, /, %)
  • Output text and variable values to the console
  • Handle type conversion and casting
  • Use arithmetic operators with variables

Sample Code

// Variable declarations
int age = 25;
double salary = 50000.50;
boolean isEmployed = true;

// Arithmetic operations
int sum = 10 + 5;              // 15
int difference = 20 - 8;       // 12
int product = 4 * 5;           // 20
double quotient = 10.0 / 3.0;  // 3.3333...
int remainder = 10 % 3;        // 1

// Type casting
int x = 5;
double y = (double) x / 2;     // 2.5

// Console output
System.out.println("Age: " + age);
System.out.println("Sum: " + sum);

Strings, User Input, and Comments

  • Create and manipulate strings
  • Use common string methods (length(), substring(), indexOf(), etc.)
  • Read user input with Scanner
  • Parse input strings to appropriate data types
  • Document code with single-line and multi-line comments
  • Use JavaDoc comments to document classes and methods

Sample Code

// String operations
String name = "Java Programming";
int length = name.length();                // 16
String sub = name.substring(0, 4);         // "Java"
boolean contains = name.contains("gram");  // true

// User input with Scanner
import java.util.Scanner;

Scanner scanner = new Scanner(System.in);
System.out.print("Enter your name: ");
String userName = scanner.nextLine();
System.out.println("Hello, " + userName + "!");

System.out.print("Enter your age: ");
int userAge = scanner.nextInt();
System.out.println("You will be " + (userAge + 10) + " in 10 years.");

// Comments
// This is a single-line comment

/*
 * This is a multi-line comment
 * It can span multiple lines
 */

/**
 * This is a JavaDoc comment
 * @param args command-line arguments
 * @return void
 */

Practice Problems

Here are some practice problems to help you prepare for the sprint challenge:

Problem 1: Variable Manipulation

Write a Java program that:

  1. Declares variables for a person's name, age, and height (in meters)
  2. Calculates their height in centimeters
  3. Calculates their age in months
  4. Prints all information to the console in a readable format

Expected Output

Name: John Doe
Age: 25 years (300 months)
Height: 1.75 meters (175.0 centimeters)

Problem 2: User Input Processing

Write a Java program that:

  1. Prompts the user to enter two numbers
  2. Calculates the sum, difference, product, quotient, and remainder
  3. Prints all calculations with appropriate labels
  4. Handles potential errors (like division by zero)

Expected Output

Enter first number: 10
Enter second number: 3

10 + 3 = 13
10 - 3 = 7
10 * 3 = 30
10 / 3 = 3.3333...
10 % 3 = 1

Problem 3: String Manipulation

Write a Java program that:

  1. Prompts the user to enter a sentence
  2. Counts the number of words, characters, and spaces
  3. Converts the sentence to uppercase and lowercase
  4. Checks if the sentence contains a specific word (e.g., "Java")
  5. Prints all this information to the console

Expected Output

Enter a sentence: Java programming is fun and challenging.

Original: Java programming is fun and challenging.
Words: 6
Characters: 41
Spaces: 5
Uppercase: JAVA PROGRAMMING IS FUN AND CHALLENGING.
Lowercase: java programming is fun and challenging.
Contains "fun": true
Contains "boring": false

Preparing for the Sprint Challenge

The best way to prepare for the sprint challenge is to practice writing code and applying the concepts you've learned. Try solving the practice problems above, and then create your own variations to further test your understanding.

Remember that during the sprint challenge:

  • You'll need to apply multiple concepts together
  • Understanding the requirements is half the battle
  • Testing your code thoroughly is crucial
  • Good documentation and code organization matters

Good luck with your sprint challenge! Review the core concepts, practice coding, and approach the challenge with confidence in your abilities.