Guest User

Untitled

a guest
Jul 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. val x = List((("Burger and chips",4.99),4.99,1), (("Pasta & Chicken with Salad",8.99), 8.99,2), (("Rice & Chicken with Chips",8.99), 8.99,2))
  2.  
  3. x.foreach(x => println(x._3 + " x " + x._1 +"tttt"+"$"+x._2 * x._3 ))
  4.  
  5. 1 x (Burger and chips,4.99) $4.99
  6. 2 x (Pasta & Chicken with Salad,8.99) $17.98
  7. 2 x (Rice & Chicken with Chips,8.99) $17.98
  8.  
  9. 1 x (Burger and chips,4.99) $4.99
  10. 2 x (Pasta & Chicken with Salad,8.99) $17.98
  11. 2 x (Rice & Chicken with Chips,8.99) $17.98
  12.  
  13. x.foreach {
  14. case (text, price, amount) => println(f"$amount x $text%-40s $$${price*amount}")
  15. }
  16.  
  17. // prints:
  18. 1 x (Burger and chips,4.99) $4.99
  19. 2 x (Pasta & Chicken with Salad,8.99) $17.98
  20. 2 x (Rice & Chicken with Chips,8.99) $17.98
Add Comment
Please, Sign In to add comment