Showing posts with label Flux Control. Show all posts
Showing posts with label Flux Control. Show all posts

Java Video Lessons - using loop and control statements WHILE, FOR, DO WHILE and SWITCH


This video is from the New Boston project: http://thenewboston.org/ , made by Bucky Roberts.
We just find the best Java video lesson for your.

In this video tutorial, Buckey will teach us more about the loops and control statements in Java.

Java Video lesson - How to use the conditional test IF ELSE

This video is from the New Boston project: http://thenewboston.org/ , made by Bucky Roberts.
We just find the best Java video lesson for your.

In this video tutorial, Buckey will teach us more about the IF conditional test in Java.
We already explained about how to use IF and ELSE conditionals test.

The FOR loop for Arrays: the for each loop


Throughout you Java programmer career, you will use the common for control statement to iterate through all the elements of an Array.

If this is so important and used, it should have a shortcut or easier way to do this in Java, don't you think?
And yes, there is a simple way.
Not to mention that with conventional arrays and for loop, it is quite easy to roll up and make mistakes.

Learn a special way to use the loop and stop having problems: foreach loop

Questions about if else conditionals


0. Write a program that receives the radius of a circle and shows the diameter and length of this area.

1. Write a program that receives three integers and tell which one is the highest and which the lowest. Can you create more than one solution?

2. Write a Java program that takes an integer and tell whether it is even or odd
Use the mathematical operator % (remainder of the division or module) and if conditional test.

3. Write a program that asks the coefficients of a quadratic equation and displays the roots of the equation, whether real or complex.
Solution

Challenge: Write a Java application that generates a random integer number between 1 and 10, and through conditional tests you have to guess what number this is.
What is the best technique, which guesses at least possible chance?

To generate a random number in the integer variable 'num_aleatorio', add in your program:
import java.util.Random;

To generate random numbers, create a type Random 'randomGenerator':
RandomGenerator Random = new Random ();

And declare a variable to receive the random number like this:
randomNum = randomGenerator.nextInt(10) + 1;

Game: Guess the number raffled by the computer



How to make a game in Java, just using one method, if else conditional test, do while control statement and Random and Scanner classes.Play a game is very good and fun... but playing a game that you have created, is a pleasure that just a few have.
The Java programming language is known to be widely used for creating games. Most likely you've played a game, even online ones, are done in Java.

Based on the knowledge gained in our online course of Java, it is possible to create a game.
Although very simple, it is quite genious and cool.

The computer will randomly select a number between 1 and 1000 and you have to guess what number this is.
Each round you enter a number and the computer will give you the tips, saying the number you typed is greater or less than the number it choose.

Ends when you hit, and he keeps the number of attempts you made. Can you beat your own record?
You know what's the best strategy?

Program that says how many days the month has


Programa em Java que recebe o mês e informa quantos dias ele possui.Exercise:

Create a Java program that receives an integer of 1 to 12, representing the months of the year and return the number of days in the month.
Use switch and not use 'case' in it.
Use accumulation case.




The command switch: making choices in Java


In the article about the while loop in our online Progressive Java course, we show how to create a simple menu.
But Java has a specific feature for this purpose, which allows us to choose something, depending on what we typed, is the command switch.

The break and continue commands: interrupting and changing flows and loops


In this part of our online Java Course we will see the break and continue commands, Java, which serve to provide us with greater control over the flow of applications, especially the iterations of loops.

Loop do while: the control statement that always happens...at least once


We will see in this article another important loop in Java, do ... while loop that always executes the code of the loop at least once, regardless of the condition of the while being true or false.

Flux Control


Loopings, Flux and Statements Control

01. How to use IF and ELSE: Testing and Controlling which will run
    Application: Say if you got straight approval, or have to do recovery test or failed
    Application: Determines the roots of a second degree equation
    Video lesson: Java Video lesson - How to use the conditional test IF ELSE
02. Questions about IF ELSE use
03. Math Operators Increment (++) and Decrement (--)
04. Assignment Operators: +=, -=, *=, /= and %=
05. Assignment operators and increment and decrement: differences between a=b++ and a=++b
06. The while loop: what it is, how to use and calculating AP and GP series with while
07. Infinite loop, controlling loops and loops with while statement
    7.1 Exercises about the while looping
08. Control Statement for: having better control over repetitions
    8.1 Exercises about control statement for
09. The do while loop: the control statement that always happens..at least once
10. The break and continue commands: interrupting and changing flows and loops
11. switch command: makind choices in Java
12. Problems involving control statement: if, else, while, for, do while and switch
      Exercise: Program that says how many days the month has
      Video lesson: using loop and control statements WHILE, FOR, DO WHILE and SWITCH

Game: How to program the Battleship game in Java

Battleship game in Java: How to program


How to make a Battleship game in Java. Commented and explained code in step-to-step for Java beginnersNow, that we already learned how to pass arrays (of any size) for methods, we can do something more useful. Let's do the famous game called naval battle, in text mode.

We use everything we have learned so far in our Java course: if else, while loop, loop, methods, random numbers, arrays, multidimensional arrays and creativity.

Exercises about the for looping


Using the for loop, create the following programs in Java:

Question: program that generates 20 numbers between 1000 and 1999 and shows that leave the rest in division 5 of 11


Build a Java application to generate 20 numbers from 1000 to 1999 and show those that divided by 11 let rest 5.

Application: Determines the roots of a second degree equation



Create a program in Java, which receives the coefficients of an equation of the second degree and return their roots.

A quadratic equation is an equation where:
ax ² + bx + c = 0, with 'a' different from 0


Control Statement for: having bettter control over the repetitions


We will now see the most important and used Java control statemente, which is always seen in our course code: the for loop

His fame is due to the power we have because of the details that the loop is able to receive, and you can have more control over the repetitions.

Exercises about the while looping


Using the while loop, create the following programs in Java:

Infinite loop, controlling loops and loops with while statement


Use looping statements often can be a dangerous task.
This is because of a thing called an infinite loop.

It happens unintentionally, but sometimes it happens on purpose ... mainly by bad intentioned people.
In this Java article we study more about this type of loop, how they occur, and how  have more control over the loopings statements.

The while loop: what it is, how to use and calculating AP and GP series with while


In recent articles we learned several operators and shortcuts used by Java programmers, such as ++, --, +=, -=, *=, /= and other.

It's time to put them in action and learn one of the most important commands in any programming language: the control statements

In this article, we'll explain what it is and how to use the while loop.

Java, Program: Say if you got straight approval, or have to do recovery test or failed


Problem: Create a program that receives a grade (use Scanner class) and check if you got approved straight, have to do a test recovery or failed.
The rule is as follows:
Grade 7 or more: approved straight
Between 5 and 7: is entitled to make a recovery test
Below 5: Direct disapproved

Java, how to use IF and ELSE: Testing and Controlling what will run


So far our codes were procedural. That is, following an order of execution: from beginning to the end, running everything.

But everything ran whenever we use a program?
Of course not, some yes, other not. We make choices.

That's what makes the if else, allows us to choose to do certain things.