Skip to content

Introductory programming exercises for ThoughtWorks University

Notifications You must be signed in to change notification settings

littlejuh/java-intro-exercises

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Introductory Programming Exercises: Java

The rules for these exercises are:

  • You are not required to submit them.
  • You must commit them in version control (GitHub) when complete. It would be smart for you to commit every 15 minutes.
  • You must implement and run them in IntelliJ/Java.

Exercises

Triangles

  1. Easiest

    Print one asterisk to the console.

    Example:

    *
    
  2. Draw a horizontal line

    Given a number n, print n asterisks on one line.

    Example when n=8:

    ********
    
  3. Draw a vertical line

    Given a number n, print n lines, each with one asterisks.

    Example when n=3:

    *
    *
    *
    
  4. Draw a right triangle

    Given a number n, print n lines, each with one more asterisk than the last (i.e. one on the first line, two on the second,etc.)

    Example when n=3:

    *
    **
    ***
    

Diamonds

  1. Isosceles triangle

    Given a number n, print a centered triangle.

    Example for n=3:

      *
     ***
    *****
    
  2. Diamond

    Given a number n, print a centered diamond.

    Example for n=3:

      *
     ***
    *****
     ***
      *
    
  3. Diamond with name

    Given a number n, print a centered diamond with your name in place of the middle line.

    Example for n=3:

      *
     ***
    Bill
     ***
      *
    

FizzBuzz

FizzBuzz is a simple number game where you count, but say "Fizz" and/or "Buzz" instead of numbers adhering to certain rules.

Create a FizzBuzz() method that prints out the numbers 1 through 100. Instead of numbers divisible by three print "Fizz". Instead of numbers divisible by five print "Buzz". Instead of numbers divisible by three and five print "FizzBuzz".

Sample Output:

1
2
Fizz
4
Buzz
Fizz
7
8
Fizz
Buzz
11
Fizz
13
14
FizzBuzz

Prime Factors

Write a method generate(int n) that given an integer N will return a list of integers such that the numbers are the factors of N and are arranged in increasing numerical order.

For example, generate(1) should return an empty list and generate(30) should return the numbers: 2,3,5.

About

Introductory programming exercises for ThoughtWorks University

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%