CommencerCommencer gratuitement

Printing as a calculator

Java can be used for quick calculations, just like a calculator! Instead of manually computing values, you can use System.out.println() to display the result of an arithmetic operation.

Complete the program to print the sum of two numbers.

Cet exercice fait partie du cours

Introduction to Java

Afficher le cours

Instructions

  • Print the result of 1+3 to the output.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

class Calculator {
	public static void main(String[] args) {
    	// Print the result of 1+3
        System.out.println(____ + ____);
    }
}
Modifier et exécuter le code