ComenzarEmpieza gratis

Increment by one

Countdowns are fun, especially for things like birthdays, product or rocket launches. Now you have the option to simulate one below!

Este ejercicio forma parte del curso

Introduction to Java

Ver curso

Instrucciones del ejercicio

  • Use the increment operator ++ to add one to age.
  • Use the decrement operator to subtract one from days.

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

class AddOne {
    public static void main(String[] args) {
    	
        int age = 30;
        int days = 20;
        System.out.println("I'm " + age + " today.");
        
        // Increment the age by 1
        ____;
        
       	// Decrement the days by 1
       	____;
        
        System.out.println("But I'll be " + age + " soon!");
        System.out.println("Only " + days + " to go!");
    }
}
Editar y ejecutar código