September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
48
Task/Multiplication-tables/Scala/multiplication-tables.scala
Normal file
48
Task/Multiplication-tables/Scala/multiplication-tables.scala
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
//Multiplication Table
|
||||
|
||||
object mulTable{
|
||||
def main( args:Array[String] ){
|
||||
|
||||
print(" |") //Horizontal row
|
||||
for( i <- 1 to 12 )
|
||||
if( i<10 )
|
||||
print( " " + i )
|
||||
else
|
||||
print(" " + i )
|
||||
println("")
|
||||
println("---------------------------------------------------------------------")
|
||||
|
||||
for( i <- 1 to 12 ){
|
||||
|
||||
if( i<10 ) //Vertical column
|
||||
print(" " + i + "|" )
|
||||
else
|
||||
print(" " + i + "|" )
|
||||
|
||||
|
||||
for( j <- 1 to 12 ){
|
||||
|
||||
if( i*j < 10 ){
|
||||
if( i<=j )
|
||||
print(" " + i*j )
|
||||
else
|
||||
print(" ")
|
||||
}
|
||||
else if( i*j < 100 ){
|
||||
if( i<=j )
|
||||
print(" " + i*j )
|
||||
else
|
||||
print(" ")
|
||||
}
|
||||
else{
|
||||
if( i<=j )
|
||||
print(" " + i*j )
|
||||
else
|
||||
print(" ")
|
||||
}
|
||||
}
|
||||
println("")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue