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 exercício faz parte do curso
Introduction to Java
Instruções do exercício
- Use the increment operator
++to add one toage. - Use the decrement operator to subtract one from
days.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
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!");
}
}