Menu
Coddy logo textTech

Basic Operations

Part of the Fundamentals section of Coddy's Java journey — lesson 40 of 73.

challenge icon

Challenge

Beginner

Add the basic arithmetic operations (addition, subtraction, multiplication, and division) on num1 and num2. Store the results in variables named sum, difference, product, and quotient, respectively. Print the results to the console using System.out.println in the following format:

Sum: [sum]
Difference: [difference]
Product: [product]
Quotient: [quotient]

Try it yourself

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        System.out.println("Calculator App");

        Scanner scanner = new Scanner(System.in);
        double num1 = scanner.nextDouble();
        double num2 = scanner.nextDouble();

        System.out.println("First number: " + num1);
        System.out.println("Second number: " + num2);
    }
}

All lessons in Fundamentals