Assignment 1: The Basics Assignment 2: Guess a Number Assignment 3: Roshambo!

Back to Basics Java Programming

Sometimes it’s good to just go back to the basics. To complete this task, here’s what you’ll need to know:

  • How to create a Java class
  • How to add Java’s special main method
  • How to declare String and int variables
  • How to do a conditional if else statement
  • How to do an iterative while loop

Could you do this?

If you were tasked with this assignment, could you do it?

  • Create a Java class named JavaBasics
  • Add the famous main method
  • Declare a variable of type int and assign it the value of 1
  • Create an infinite while loop where the condition is simply (true)
  • Print out the value of the variable on every iteration of the loop
  • Increase the int by one every time the loop iterates
  • Break out of the loop with a return; if the number is greater than ten

Hints

Here are some hints.

A Java class looks something like this:

public class Customer {

}

The main method is public, it sticks to your clothes when you pull it out of the dryer, it is like an uncashable check, its name is obvious, and it tends to get into arguments with twine.

Conditional statements are just if..else blocks

if (true) { }
else { }

While loops are just a boolean condition and a code block

while(true) {  }

So, what would your code look like?