You are on page 1of 5

PARUL UNIVERSITY

FACULTY OF ENGINEERING & TECHNOLOGY


Big Data Analytics (203105443) B.Tech. 3rd Year
Practical No 08
Aim: To perform the experimentation and get hands on Scala Programing language.
Tools: Scala online complier.
Theory:
1) Scala stand for “Scalable Language”, designed by Martin Odersky.
2) It is a multi-paradigm programing language.
3) Scala include the feature of functional programing and object oriented programing language.
4) Its statically typed language, its source code is compiled into byte code and executed by Java Virtual Machine
(JVM).
5) Scala support scala or .sc filename extension.

Observations: The observation task is below


Task 01: Write any program in Scala in which without declaration data type & with declaration of data type.

Theoretical Approach:
//creating object
object Demo //Demo is object Name
{
//declaring method
def main(args : Array[String])
{
//With declaration of Data types
var myVar: Int =10;
val myVal: String = “Hello scala with datatype decleration”;
//Without declaration of data type
var myVar1 = 20;
val myVal1 = “Hello scala with datatype declaration”;
//method1 to print result
println(myVar); println(myVal);
//method2 to print result
println (myVar1);
println (myVal1);
}
}

Expected Output: 10
Hello scala with datatype decleration.
20
Hello scala without datatype decleration.

Y.NAGA SAI SARAVANAN


200303125070
PARUL UNIVERSITY
FACULTY OF ENGINEERING & TECHNOLOGY
Big Data Analytics (203105443) B.Tech. 3rd Year
Practical Approached:

Actual Output:

Task 02: Create an object named “scala”, take a variable “value” and assign the value ‘50’.
check if the value is equal to 20 so display “value is 20” , value is equal to 25 so display “value
is 25”, value is equal to 40 so display “value is 40”, either display “No match Found”.
Theoretical approached:
//Creating Object
object scala //Scala is a object name
{
//calling main method
def main(args : Array[String])
{
//Take a variable
var value : Int = 50;

Y.NAGA SAI SARAVANAN


200303125070
PARUL UNIVERSITY
FACULTY OF ENGINEERING & TECHNOLOGY
Big Data Analytics (203105443) B.Tech. 3rd Year
if (value == 20){
//if above condition is matched
Condition 01
println(“value is 20”) ;
}
else if (value == 25){
//if the above condition is true
Condition 02
println(“value is 25”);
}
else if (value == 40){
println (“Value is 40”); Condition 03
}
else{
println (“No Match found”);
Condition 04
}

}
}
Expected Output: No Match found

Practical Approached:

Actual Output:

Y.NAGA SAI SARAVANAN


200303125070
PARUL UNIVERSITY
FACULTY OF ENGINEERING & TECHNOLOGY
Big Data Analytics (203105443) B.Tech. 3rd Year

Task 03: Write a program in scala to print infinite even number from 10.
Theoretical Approched:
//Creating Object
object MainObject //MainObject is object name
{
//Calling method
def main(args : Array[String])
{ //Take a variable
var a = 10;
do {
println(a);
a =a+2; //Incrementation
}
while(true)
}
}

Expected Output:
10
12
14
16
18
…………
Ctrl+z //To stop excutetion program

Practical Approached:

Y.NAGA SAI SARAVANAN


200303125070
PARUL UNIVERSITY
FACULTY OF ENGINEERING & TECHNOLOGY
Big Data Analytics (203105443) B.Tech. 3rd Year

Actual Output:

Result:
The theoretical approach and practical approached is exact same and actual
and expected output is also exactly same.

Conclusion:
From this experiment I concluded that, Actual and Expected output is
matched hence the objective this practical or experimentation is successfully
completed.

Y.NAGA SAI SARAVANAN


200303125070

You might also like