Java I

Java for Beginners


Progress
Reviewed: 0%
8 Tasks


Ideal for someone who has a zero knowledge of Java or any programming language, Java is one of the most widely used programming languages in the world. Java is also an excellent language to learn if you want to pursue a career in software development.


  • Day 2
  • DataTypes

    Concept:



    Resources:



    Assignments:


    You are tasked with writing a Java program that demonstrates your knowledge of different data types. Your goal is to declare variables of various data types, assign them specific values, and print their values along with descriptions.

    Output:
    Integer Variable: 42
    Double Variable: 3.14159
    Character Variable: A
    Boolean Variable: true
    String Variable: Hello, SkillCaptain!



  • Day 3
  • Primitive Vs Boxed DataType

    Concept:



    Resources:



    Assignments:


    Write a Java program that greets the user with a predefined age (an integer value) and a predefined name (a string value). The program should store the age as a primitive type (int) and the name as a boxed type (String).

    Output:
    Hello, Skill Captain! You are 25 years old.

    Explanation: :
    Your program should greet the user using the provided predefined values for age and name.



  • Day 4
  • Conditions

    Concept:



    Resources:



    Assignments:


    You are tasked with writing a Java program that determines and outputs the larger of two predefined integer values.
    Your goal is to modify the program to achieve the following:
    Set two integer variables, num1 and num2, with predefined values. For example, set num1 to 10 and num2 to 20.
    Implement a conditional statement to compare the values of num1 and num2.
    Print out the larger of the two values.

    Output:
    For example, with num1 set to 10 and num2 set to 20, your program should output:
    The larger number is: 20



  • Day 5
  • Make a calculator

    Concept:



    Resources:



    Assignments:


    You are tasked with writing a Java program named "Calculator" that performs basic arithmetic operations on two predefined integer values based on a predefined operator.
    Your goal is to modify the program to achieve the following:
    Set two integer variables, num1 and num2, with predefined values. For example, set num1 to 10 and num2 to 5.
    Set a character variable operator to a predefined arithmetic operator. For example, set operator to '+'.
    Implement conditional statements to perform the operation based on the operator. Supported operators are '+', '-', '*', and '/'.
    Print out the result of the operation in the format: num1 operator num2 = result.

    Output:
    For example, with num1 set to 10, num2 set to 5, and operator set to '+', your program should output:
    15



  • Day 6
  • Loop

    Concept:



    Resources:



    Assignments:


    Write a Java program that demonstrates the use of different types of loops:
    1. Using a FOR loop, print the numbers from 1 to 10 in ascending order.
    2. Using a WHILE loop, print out the even numbers between 1 and 20 (inclusive) in ascending order.
    3. Write a Java program that utilizes a DO-WHILE loop to demonstrate the validation of a number within the range of 1 to 10.
        Your task is to modify the program to achieve the following:
         Set a predefined integer variable, userNumber, with a value within the range of 1 to 10.
         Implement a do-while loop to simulate the process of validating the number.
         Within the loop, check if userNumber is within the valid range (1 to 10). If it is, exit the loop.
         After exiting the loop, print out a message that says "You entered [userNumber].

    Output:
    1 2 3 4 5 6 7 8 9 10
    2 4 6 8 10 12 14 16 18 20
    You entered 3.

    Explanation: :
    For example, with userNumber set to 3, your program should output You entered 3. for 3rd case.



  • Day 7
  • Array

    Concept:



    Resources:



    Assignments:


    Write a Java program that performs the following tasks:
     1. Create an array of 5 integer values with the any elements: like [10, 5, 15, 7, 20].
     2. Calculate and print the sum of all the values in the array.
     3. Calculate and print the average (mean) of the values in the array.
     4. Find and print the maximum value among the elements in the array.
     5. Find and print the minimum value among the elements in the array.

    Output: :
    Sum: 57
    Average: 11.4
    Maximum: 20
    Minimum: 5

    Explanation: :
    The provided output explanation corresponds to the array [10, 5, 15, 7, 20]



  • Day 8
  • List

    Concept:



    Resources:



    Assignments:


    You are tasked with creating a Java program called "GroceryListManager" that allows a user to manage their grocery list.
    The program should provide the following functionalities:
     1. Add Items to the Grocery List: Users should be able to add items to their grocery list. Each item has a name and an optional quantity.
     2. Remove Items from the Grocery List: Users should be able to remove items from their grocery list based on the item name.
     3. Print the Current Grocery List: Users should be able to view the current list of items on their grocery list.
     4. Check if a Specific Item is on the Grocery List: Users should be able to check if a specific item is already on their grocery list.
     5. Clear the Entire Grocery List: Users should be able to clear the entire grocery list, removing all items.

    Explanation: :
    Example Data for Grocery List:
    Initial Grocery List: []
    After Adding "Apples" (Quantity: 5): ["Apples (Quantity: 5)"]
    After Adding "Bananas" (Quantity: 2): ["Apples (Quantity: 5)", "Bananas (Quantity: 2)"]
    After Removing "Apples": ["Bananas (Quantity: 2)"] After Clearing the List: []



  • Day 9
  • Map

    Concept:



    Resources:



    Assignments:


    Word Frequency Counter
    Create a program that reads a paragraph of text and counts the frequency of each word in the paragraph. The program should display the word and its corresponding frequency.

    Requirements:
    Use a HashMap to store the word-frequency pairs.
    Prompt the user to enter a paragraph of text.
    Split the paragraph into individual words and count the frequency of each word.
    Display the word and its frequency.

    Output:
    ["The: 2", "quick: 1", "brown: 1", "fox: 1", "jumps: 1", "over: 1", "the: 3", "lazy: 1", "dog: 2", "barks: 1", "loudly: 1"]

    Explanation:
    paragraph: "The quick brown fox jumps over the lazy dog. The dog barks loudly."



  • Day 10
  • Set

    Concept:



    Resources:



    Assignments:


    Create a set of integers, and your task is to perform various operations on this list, simulating a set of unique numbers. Implement a program with the following operations:
    Operations:
     1. add(int num): Adds an integer to the set if it doesn't already exist.
     2. remove(int num): Removes an integer from the set if it exists.
     3. contains(int num): Checks if the set contains a specific integer and returns a boolean value.
     4. size(): Returns the number of unique integers in the set.
     5. isEmpty(): Checks if the set is empty and returns a boolean value.

    Explanation: :
    Given the Set: [5, 10, 15]
    Perform the following operations:
     add(10): Add 10 to the set. Set: [5, 10, 15]
     add(20): Add 20 to the set. Set: [5, 10, 15, 20]
     remove(5): Remove 5 from the set. Set: [10, 15, 20]
     remove(25): Attempt to remove 25 (not in the set). Set: [10, 15, 20]
     contains(10): Check if 10 is in the set. Result: true
     contains(25): Check if 25 is in the set. Result: false
     size(): Get the size of the set. Result: 3
     isEmpty(): Check if the set is empty. Result: false



×

Let's Go!

Congratulations on getting started. Here is a little reward for you...

×

10

Going to the next task in