Week 7

Source Code

import java.util.*;

public class Week7 {
    public static void main(String[] args) {
        String myName = ""; // add your name
        System.out.println("Week 7");
        System.out.println("Name: " + myName);

        // Example 1
        // Recommended way
        
        // Deprecated since Java 9
        

        // Example 2
        // Autoboxing
        

        // Example 3
        

        // Example 4
        // Recommended way
        
        
        // Deprecated since Java 9
        
        
        // Autoboxing
        


        // Example 5
        

        // Example 6
        

        // Example 7
        

        // Example 8
        

        // Example 9
        

        // Example 10
       

        // Example 11
       

        // Example 12
        

        // Example 13
        
    }
}

W7Problem1.java

import java.util.*;

public class W7Problem1
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        System.out.print("How old are you? ");
        String ageStr = in.nextLine(); // don't modify!
        System.out.print("How many years till graduation? ");
        String gradStr = in.nextLine(); // don't modify!
        
        
        
        System.out.println("I am.. ");
        System.out.println("In 10 years, I will be.. ");
        System.out.println("In 20 years, I will be.. ");
        System.out.println("In 30 years, I will be.. ");
        
        
    }   
}

W7Problem2.java

public class W7Problem2
{
    public static void main(String[] args)
    {
    
    
    }
}

W7Problem3.java

public class W7Problem3
{
    public static void main(String[] args)
    {
    
    
    }
}

W7Problem4.java

public class W7Problem4 {
    
    public static void main(String[] args) {
        // Define the coordinates of two points


        // Calculate the differences in x and y coordinates


        // Calculate the square of the distance using Math.pow


        // Get the actual distance using Math.sqrt


        // Output the results

    }
}

W7Problem5.java

public class W7Problem5 {

    public static void main(String[] args) {
        // Define the coordinates of two points in 3D space


        // Calculate the differences between the corresponding coordinates


        // Use Math.abs to convert differences to absolute values


        // Calculate the square of the distance using Math.pow


        // Calculate the actual distance using Math.sqrt
 

        // Print out the results

    }
}

W7Problem6.java

public class W7Problem6
{
    public static void main(String[] args)
    {
        // 1. Use Math.random() to generate 3 integers from 0-40 (not
        // including 40) and print them out.


        // 2. Calculate the number of combinations to choose 3 numbers between
        // 0-40 (not including 40) using Math.pow() and print it out.
        // For example, Math.pow(10,2) is 10^2 and the number of permutations
        // to choose 2 numbers between 0-9.

    }
}

W7Problem7.java

public class W7Problem7
{
    public static void main(String[] args)
    {
    
    
    }
}

W7Problem8.java

public class W7Problem8
{
    public static void main(String[] args)
    {
    
    
    }
}

Last updated

Was this helpful?