0% found this document useful (0 votes)
14 views2 pages

Practical 13

The document contains an assignment for a Scala program that determines if a given number is positive or negative using an 'if' statement. It includes the program code and sample output demonstrating the functionality. The program prompts the user to enter a number and prints whether it is positive or negative based on the input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views2 pages

Practical 13

The document contains an assignment for a Scala program that determines if a given number is positive or negative using an 'if' statement. It includes the program code and sample output demonstrating the functionality. The program prompts the user to enter a number and prints whether it is positive or negative based on the input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment No 13

Name : Kadam Arati Dilip RollNO:COTA29


Write a simple program in SCALA using Apache Spark framework.

Spark installation:

Scala Program:
Find given number is Positive/Negative using ‘If’ Statement.

Output:
1 // Scala program to find given number is POSITIVE/NEGATIVE
2 // using "IF"
statement 3
4 object Sample{
5 def main(args:Array[String]){
6 var num:Int = 0;
7
8 print("Enter number:")
9 num=scala.io.StdIn.readInt()
10
11 if(num>=0)
12 println("Number is POSITIVE")
13 else
14 println("Number is NEGATIVE")
15 }
16 }
17
18
19
20 /*
21 Output:
22 sham@sham-VirtualBox:~/spark$ scalac program.scala
23 sham@sham-VirtualBox:~/spark$ scala Sample
24 Enter number:-32
25 Number is NEGATIVE
26 sham@sham-VirtualBox:~/spark$ scala Sample
27 Enter number:25
28 Number is POSITIVE
29 */

You might also like