Advertisement
Eugene0091

Untitled

Oct 29th, 2020
2,940
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.86 KB | None | 0 0
  1.         if (inp == 1) {
  2.             println("you typed 1!");
  3.         } else if (inp == 2) {
  4.             println("you typed 2!");
  5.         } else if (inp == 3) {
  6.             for (i <- 1 to 5) {
  7.                 if (i > 3) {
  8.                     println(0);
  9.                 }
  10.                 else println(inp);        
  11.             }
  12.                                
  13.         }
  14.         else if (inp == 4) {
  15.             var i = 0;
  16.             while (i < 10) {
  17.                 if (i % 2 == 0)
  18.                     println(inp);
  19.                 else println(0);
  20.             }          
  21.         }
  22.         else {
  23.           for (int i = 1; i < 5; ++i) {
  24.             inp match{
  25.                 case 1 => println("123123");
  26.                 case 7 => println("you typed 7!");
  27.                 case _ => println("inp is out of range(1..7)");
  28.             }}
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement