From the course: Java 11+ Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: A simple calculator - Java Tutorial
From the course: Java 11+ Essential Training
Solution: A simple calculator
(upbeat electronic music) - [Instructor] In the previous video, I issued a challenge, create a very simple calculator application that can receive two values with fractions, and then divide one number by the other. I'll show you the code that I created to accomplish this. As in a previous video, I created an instance of the scanner class that collects information from system.in. This is something called an input stream and it's data provided by the user in a console application. I used system.out.print without the print line to display prompts, and then after each prompt I received some data. Instead of using next line or next int as I did previously, I used the next double method, and that allows me to receive a numeric value that has a fraction. I received two variables that I named d1 and d2, you could name them anything you want, and then I divided one number by the next. And then I displayed the result. Now…
Contents
-
-
-
-
-
-
Declare and initialize string values3m 55s
-
Build a string from multiple values4m
-
Clone the exercise files from GitHub3m 57s
-
Convert primitive values to strings3m 29s
-
Format numeric values as strings5m 55s
-
Interpolate strings with placeholders3m 7s
-
Compare string values4m 27s
-
Parse string values2m 36s
-
Get string values from user input3m 34s
-
Challenge: A simple calculator1m 9s
-
Solution: A simple calculator1m 18s
-
-
-
-
-
-
-