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;

No comments: