OneCompiler

pracco

213

class caccount(ano:Int,name:String,var bal:Double,mbal:Double){
def withdral()
{
var a:Int=0;
println("enter amount to withdraw");
a= scala.io.StdIn.readInt();
var temp:Double=0.0;
temp=bal;
temp=temp-a;
if(temp<mbal)
{
println("BALANCE CANNOT BE LESS THAN MINIMUM BALANCE");
}
else
{
bal=temp;
}
temp=0.0;
}
def deposit()
{
var a:Int=0;
println("\nEnter amount to deposit");
a= scala.io.StdIn.readInt();
bal=bal+a;
}
def viewbal()
{
println("\nAccount Number: "+ano + "\nAccount Holder Account: " + name+ "\nAccount Balance:
" +bal+ "\nAccount minimum balance: " +mbal);
}
}
object runclass1
{
def main(args : Array[String])
{
var ano1:Int=0;
var name1:String="";
var bal1:Double=0.0;
var mbal1:Double=0.0;
print("Enter account no: ");
ano1= scala.io.StdIn.readInt();
print("Enter customer name: ");
name1= scala.io.StdIn.readLine();
print("Enter balance: ");
bal1= scala.io.StdIn.readDouble();
print("Enter min bal: ");
mbal1= scala.io.StdIn.readDouble();
var c = new caccount(ano1,name1,bal1,mbal1);
c.deposit();
c.viewbal();
c.withdral();
c.viewbal();
}
}

class Employee{
var id:Int =0;
var name:String=null;
var salary:Double=0.0;
def accept()
{
println("Enter Emp id: ");
id= scala.io.StdIn.readInt();
println("Enter Emp name: ");
name= scala.io.StdIn.readLine();
println("Enter Emp salary: ");
salary= scala.io.StdIn.readDouble();
}
def display()
{
println("\nEmp id: "+id + "\Emp Name: " + name+ "\n Salary: " +salaryll);
}
}
object runclass2
{
def main(args : Array[String])
{
var e1 = new Employee();
var e2 = new Employee();
e1.accept();
e1.display();
e2.accept();
e2.display();
if(e1.salary>e2.salary)
println(“Max salary is “+ e1.salary);
else
println(“Max salary is “+ e2.salary);
}
}

abstract class Order(id:Int, description:String){
def display();
}
class PurchaseOrder(id:Int, description:String) extends Order (id, description){
var vendor:String = null;
def display(){
println("Enter Vender name: ");
vendor= scala.io.StdIn.readLine();
println(“ Vender name is : " + vendor);
println(“ Order Id is : “+ id);
println(“ OrderVender description is : " +description);
}
}
class SalesOrder(id:Int, description:String) extends Order (id, description){
customer:String = null;
def display(){
println("Enter customer name: ");
customer= scala.io.StdIn.readLine();
println(“ Customer name is : " + customer);
println(“ Order Id is : “+ id);
println(“ Order description is : " +description);
}
}
object runclass3 {
def main(args: Array[String]){
var p = new PurchaseOrder(203 , “computer”) ;
var c = new SalesOrder(305, “Laptop”) ;
p.display();
c.display();
}
}

abstract class Shape{
def volume();
def display();
}
class Cube extends Shape{
var a:Double = 0.0;
var v:Double = 0.0;
def volume(){
println("Enter side of cube: ");
a= scala.io.StdIn.readDouble();
v= aaa;
}
def display(){
println("Volume of Cube is : " + v);
} }
class Cylinder extends Shape{
var r:Double = 0.0;
var h:Double = 0.0;
var v:Double = 0.0;
def volume(){
println("Enter radius of cylinder: ");
r= scala.io.StdIn.readDouble();
println("Enter height of cylinder : ");
h= scala.io.StdIn.readDouble();
v = 3.14rr*h;
}
def display(){
println("Volume of Cylinder is : " + v) ;
}
}
object runclass4 {
def main(args: Array[String]){
var c1 = new Cube() ;
var c2 = new Cylinder() ;
c1.volume();
c1.display();
c2.volume();
c2.display();
} }

class Project(id:Int,name:String,location:String{
var a:Int=0;
def display()
{
a++;
println("no of object is: " + a);
println(“Project id is :” +id);
println(“Project name is :” + name);
println(“Project location is :” + location);
}
}
object runclass5
{
def main(args : Array[String])
{
var p1 = new Project(101, “Emp”,”pune”);
var p2 = new Project(102, “HRM”,”pune”);
var p3 = new Project(103, “Account”,”pune”);
p1.display();
p2.display();
p3.display();
}
}

class Sport (var id: Int, var name: String,var description:String, var amount: Int)
{
def show(){
println(“ Sports class running”)
}

}
class Indoor (var id: Int, var name: String,var description:String, var amount: Int) extends
Sports(id,name,description,amount){
override def show(){
println(“ Indoor game id is : “ + id);
println(“ Indoor game name is : “ + name);
println(“ Indoor game description is : “ + description);
println(“ Indoor game amount is : “ + amount);
}
}
class Outdoor (var id: Int, var name: String,var description:String, var amount: Int) extends
Sports(id,name,description,amount){
override def show(){
println(“ Outdoor game id is : “ + id);
println(“ Outdoor game name is : “ + name);
println(“Outdoor game description is : “ + description);
println(“ Outdoor game amount is : “ + amount);
}
}
object runclass6
{
def main(args : Array[String])
{
var I1 = new Indoor(101, “Chess” , “Play with two “ ,500);
var O1 = new Outdoor(102, “Football” , “Play with ten “ ,1500);
I1show();
O1show();
}
}

abstract class Employee{
def computesal();
}
class Worker extends Employee{
var hr:Double = 0.0;
var rate:Double = 0.0;
var tot:Double = 0.0;
def computesal(){
println("Enter no of hour emp work: ");
hr= scala.io.StdIn.readDouble();
println("Enter rate per hour of work: ");
rate= scala.io.StdIn.readDouble();
tot = hrrate;
println("Total Salary of worker is : " +tot);
} }
Class Manager extends Employee{
var basic:Double = 0.0;
var hra:Double = 0.0;
var da:Double = 0.0;
var ta:Double = 0.0;
var IT:Double = 0.0;
var PF :Double = 0.0;
var netsal:Double = 0.0;
def computesal(){
println("Enter basic salary of manager: ");
basic= scala.io.StdIn.readDouble();
hra = 0.10
basic;
ta = 0.08basic;
da = 0.12
basic;
IT = 0.15basic;
PF = 0.12
basic;
netsal = (basic+hra+da+ta) - (IT+ PF);
println("Salary of Manager is : " + netsal) ;
}
}
object runclass7 {
def main(args: Array[String]){
var e1 = new Worker() ;
var e2 = new Manager() ;
e1.computesal();
e2.computesal();
} }