Java, Programming

Java review First day: Beginner

Hi, I will be giving a class on java programming,

Today in our first lesson we are going to review/learn some printing statements, for loops and if statements.
First of all lets start by the software that we will be using for our class.
for IDEA:
IntelliJ
Download IntelliJ
Then we will have to download the java SDK:
Download Java SDK

To create a new project in IntelliJ, we click on, create new project ( the first time the project needs to be aligned with java sdk).
Then we create a package, and afterwards a java class usually with the same name of the package. It will be assigned a default constructor.

In order for the java program to run, there should be a main static method.

We will be using the scanner class today, that must be imported with:

import java.util.Scanner;

Below there is an example for the lesson of today:

Printing to the screen:
 

import java.util.Scanner;
public class Hello {
	
	public static void main(String[] args){
		System.out.println("hello Yanilda");
		System.out.print("Hey Yani");
		System.out.printf("Hi Yani");
		System.out.print("Hey Yani");
		
		for(int i=0; i<10;i++){
			System.out.println("hello Yanilda");
		}
		
		int aNumber, bNumber;
		System.out.println("enter input");
		Scanner scaner1 = new Scanner(System.in);
		Anumber=scaner1.nextInt();
		System.out.println("enter input");
		Bnumber=scaner1.nextInt();
		scaner1.close();
		int abSum=aNumber+bNumber;
		System.out.println("Sum is "+abSum);	
		
		if(abSum<10){
			System.out.println("Less than 10");
		}
		else if(abSum>10){
			System.out.println("Greater than 10");
		} 
		else{
			for(int i=0;i<5;i++){
			System.out.println(" Equal to 10");
			}
		}
	
	}
}

>>

hello Yanilda
Hey YaniHi YaniHey Yanihello Yanilda
hello Yanilda
hello Yanilda
hello Yanilda
hello Yanilda
hello Yanilda
hello Yanilda
hello Yanilda
hello Yanilda
hello Yanilda
enter input
5
enter input
5
Sum is 10
Equal to 10
Equal to 10
Equal to 10
Equal to 10
Equal to 10

Comments can be done by using:
// for one line

***** For beauty
It's always good to have documentation, name of the the program with extension, name of the author, the date and what the program does. under the import statements.

/**
* Hello.java
* Purpose: Uses if Statements and for loops, prints and gather input's user.
*
* @author Yanilda Peralta
* @version 1.0 6/05/2015
*/

Today Practice programs:
1- Create a program that asks user for name and then prints out the name + how are you?
2- Create Sum the numbers from 1 to 10 using for loops
3- Create program that takes an integer input from user and if the integer is positive prints "positive"x3, if it's negative it prints"negative"x4 and if it's zero, print neutral. Use For loops and if statements.

Indentation is needed for readability.
white space between the things that don't belong to a group.
Name convention.
Meaningful names will give you a description of the purpose of the the object/class/method/variable.
When naming variable in java, the camel style is the way to go, start with lowercase then change to Uppercase if it's a combination of words, e.g. myNumber. don't use under bars, but if wanting to use under bars, put all letters in capital, MY_NUMBER.
For Class names use Uppercase, MyClass.
For methods start with lowercase. myMethod.

For Homework submission email to:
java_homework@smartvania.com

Homework # 1 -
Create 3 different programs:
1- Ask the user for 3 inputs. Then you will decide which input is larger than the other.Then you print out the largest.
2-Reverse string in 2 different ways.
3-Do the Palindrome in 2 different ways.