This video explains athe solution to creating a payroll program in Scala. The solution uses the concepts reviewed in this section such as writing functions, creating variables and using decision statements.
(chime)…- [Narrator] Welcome back.…How did you make out with the challenge?…I hope you had fun with it.…What I'd like to do is walk you through my solution…and kind of give you some insight along the way.…Remember, everybody programs differently.…So if yours looks different than mine,…that's totally fine.…Let me add a new worksheet to my source package.…I'm going to call it payroll solution.…I'm going to start by getting rid of the print line…for the welcome.…
The first thing that I want to do is to create a variable…that will hold the hourly rate.…So I'm going to do variable rate is equal to 10.5.…Next, I'm going to go ahead and define my function.…My function is going to be called earnings.…I'm going to do d-e-f earnings.…This particular function is going to take in a string…that indicates whether it's an hourly employee…or a salaried employee.…So let's start with s colon string comma.…And it also takes in the number of hours worked…if it is an hourly employee.…
I'm going to go ahead and call that h…and I'll make that a double.…
Join Peggy Fisher as she helps get you started with Scala, so you can leverage the unique capabilities it offers. First, learn the basics of type inference, variables, loops, functions, and operators. Then, find out how to read files using a console, perform pattern matching, handle exceptions, and more. Finally, learn how to use classes, fields, methods, and objects.
- Integrating with IDEs
- Scala worksheets
- Scala repl sessions
- Type inference
- Creating variables
- Working with loops
- Higher-order functions
- Scala operators
- Working with decision statements
- Handling exceptions using try or catch
- Working with tuples and arrays
- Classes, fields, and methods
Skill Level Intermediate
Java Platforms Compared: SE vs EE vs MEwith Peggy Fisher25m 38s Intermediate
1. Getting Started with Scala
2. Scala Basics
3. More Scala Basics
4. Objects with Scala
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.