Enter your Sign-on user name and password.

Forgot password?
  • Follow us on:
Loading video...

QuickNotes™  

Loop Statements

  • Repetition: Repetition or looping is used to repeat a task in a program as many times as necessary.

  • Loops in Java: for, while, and do-while are 3 different ways Java provides for repetition.

  • Structure of a loop: All loops have 4 parts:

    • Initialization: To set the variables to a good starting point

    • Check of Condition: To evaluate the conation(s) to determine if there is a need to continue

    • Task: The process that needs to be repeated.

    • Reset condition: Changing the values to reset the condition, to ensure proper termination of the loop

  • For loop Syntax: for ( initialize ; Check condition; Reset condition) Task ;

  • 	for (int I = 0 ; I < 5 ; I++) 
    	    System.out.println(I); // Prints I (0-4)
    	
  • While loop syntax:

  • 	Initialize condition;           int  I = 0 ;
    	while (Check condition) {       while ( I < 5 ){
    	    Task;                            System.out.println(I);
    	    Reset condition;                 I++ ;
    	}                               }
    	
  • Do_while loop Syntax : This type of a loop is different in the way that it forces the task to be done at least once, by combing the initialization and reset of the condition and checking the condition at the end of the loop instead of beginning.

  • 	Declare variables               int I ;
    	                                Scanner KB = new Scanner(System.in);
    	do{                             do{
    	    Task                            System.out.println("Enter an integer 
    	                                          between 1 and 5 :");
    	    Set/reset the condition;        I = KB.nextInt();
    	}while (Condition true)	        } while ( I < 1 || I > 5);
    	
Mathematics:
Basic Math
Pre-Algebra
Algebra I
Algebra II
Geometry
Trigonometry
Pre-Calculus
Calculus I
Calculus II
Multivariable Calculus
Statistics
Chemistry:
General Chemistry
Organic Chemistry
Physics:
High School Physics
AP Physics B (Mechanics)
AP Physics C (Electricty & Magnetism)
Biology:
General Biology
AP Biology
(AP) Advanced Placement:
AP Calculus AB
AP Calculus BC
AP Biology
AP Chemistry
AP Physics B (Mechanics)
AP Physics C (Mechanics)
AP Physics C (Electricty & Magnetism)
AP Statistics
AP Computer Science: Java
Computer Science:
HTML Training
CSS Intro
Java
JavaScript
Introduction to PHP
Wordpress Training
XML Training