CARVIEW |
Select Language
HTTP/2 200
date: Thu, 16 Oct 2025 05:42:02 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=3cfb52279aaf9ca3cc98650e9d20073f1101ad1cd5f12d7725557c3b90235ce9a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%2275DzSg0VtUN9V3Yfi3dXbALxqW6XKy1n%22%3B%7D; HttpOnly; Path=/
cf-ray: 98f53b0538df8e4d-BLR
class ComplexNumber(private val re: Double, private val im: Double) { def +(o - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ComplexNumber(private val re: Double, private val im: Double) {
- def +(otherNumber: ComplexNumber) = new ComplexNumber(re + otherNumber.re, im + otherNumber.im)
- def -(otherNumber: ComplexNumber) = new ComplexNumber(re - otherNumber.re, im - otherNumber.im)
- def *(otherNumber: ComplexNumber): ComplexNumber = {
- new ComplexNumber(re * otherNumber.re - im * otherNumber.im, im * otherNumber.re + re * otherNumber.im)
- }
- def printComplex(): Unit = {
- println(s"${re} + ${im}i")
- }
- }
- object ComplexNumbersCalculator extends App {
- private def createComplexNumberFromConsole() = {
- println("Enter real part:")
- val re = scala.io.StdIn.readDouble()
- println("Enter imaginary part:")
- val im = scala.io.StdIn.readDouble()
- new ComplexNumber(re, im)
- }
- private var continue = true
- while (continue) {
- val num1: ComplexNumber = createComplexNumberFromConsole()
- val num2: ComplexNumber = createComplexNumberFromConsole()
- println("Choose operation ['+', '-', '*']:")
- val operation = scala.io.StdIn.readChar()
- if (operation == '+') {
- (num1 + num2).printComplex()
- } else if (operation == '-') {
- (num1 - num2).printComplex()
- } else if (operation == '*') {
- (num1 * num2).printComplex()
- } else {
- println("Unknown operation!")
- }
- println("You want continue? (Y/n)")
- val continueRequest = scala.io.StdIn.readChar()
- continue = if (continueRequest == 'Y') true else false
- }
- println("Bye bye!")
- }
Advertisement
Add Comment
Please, Sign In to add comment
-
✅⭐ Make huge profits on trading ⭐⭐ T
JavaScript | 6 sec ago | 0.25 KB
-
✅ Marketplace Glitch ✅ Working NEVER SEEN BE...
JavaScript | 14 sec ago | 0.25 KB
-
📌 Instant BTC Profit Method ✅ Working 7
JavaScript | 31 sec ago | 0.25 KB
-
✅ Make $2500 in 20 minutes⭐ 0
JavaScript | 39 sec ago | 0.25 KB
-
📌 Swapzone +37% glitch ⭐ A
JavaScript | 47 sec ago | 0.25 KB
-
✅⭐ Make huge profits on trading ⭐⭐ T
JavaScript | 55 sec ago | 0.25 KB
-
✅ Marketplace Glitch ✅ Working NEVER SEEN BE...
JavaScript | 1 min ago | 0.25 KB
-
⭐✅ Exploit 2500$ in 15 Minutes⭐⭐⭐ X
JavaScript | 1 min ago | 0.25 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand