package pl.pp; import java.util.Scanner; public class mySecondApp { public static void main(String[] args) { //this is a line comment Scanner scanner = new Scanner(System.in); /* This is a block comment it can have multiple lines just like here */ double x = 10; // creating a double type variable and assigning it a value of 10 double y = 2; scanner = new Scanner(System.in); var result = x + y; System.out.println("x + y = " + result); result = x - y; System.out.println("x - y = " + result); result = x * y; System.out.println("x * y = " + result); result = x / y; System.out.println("x / y = " + result); result = x % y; System.out.println("x % y = " + result); System.out.println("Enter two numbers separated by the Enter key:"); double first = scanner.nextDouble(); //reguest to enter a double value double second = scanner.nextDouble(); System.out.println("x + y = " + (first + second)); System.out.println("Please enter your name:"); String forename = scanner.nextLine(); System.out.println("Please enter your surname:"); String surname = scanner.nextLine(); scanner.close(); System.out.println("Welcome " + forename + " " + surname); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter