Lab 2 task 1
Sun Mar 10 2024 15:54:33 GMT+0000 (Coordinated Universal Time)
Saved by
@brhm_lifter
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);
}
}
content_copyCOPY
Comments