ComenzarEmpieza gratis

Performing calculations

You can use numbers and variables to do maths in Java! Time to practice some basic calculations.

Este ejercicio forma parte del curso

Introduction to Java

Ver curso

Instrucciones del ejercicio

  • Save the result of 5 plus 6 into the int called varA.
  • Save the result of varA minus 3.5 into the double called varB. Use the varA.
  • Save the result of 3 times 3 into the int called varC.
  • Save the result of varC divided by 3 into the int called varD1 and also to a double called varD2.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

class BasicMaths {
    public static void main(String[] args) {
    
    	// Save the result of 5 plus 6 to varA
        int varA = ____ ____ ____;
        
        // varB is varA minus 3.5
        double varB = ____;
        
        // varC is 3 times 3
        ____; 
        
        // varD1 is varC divided by three, as int
        int varD1 = ____;
        
        // varD2 is varC divided by three, as double
        ____;   
        
        System.out.println("int varD1: " + varD1);
        System.out.println("double varD2: " + varD2);
	}
}
Editar y ejecutar código