![Java Scanner Program to read three inputs Java Scanner Program to read three inputs](https://code2care.org/program/how-can-you-read-three-different-values-using-scanner-java-program/images/Java Scanner Program to read three inputs.png)
Java Scanner Program to read three inputs
Program: How to read three different values using Scanner in Java?
Code:
import java.util.Scanner;
/**
*
* Program to read three integers
* as input using Scanner Class
*
*
* Code2care.org Java Programs
* Update: 19 March 2022
*
**/
public class ScannerReadExample {
public static void main(String... args) {
Scanner scannerObject = new Scanner(System.in);
System.out.print("Enter value of first Integer: ");
int firstInteger=scannerObject.nextInt();
System.out.print("Enter value of second Integer: ");
int secondInteger=scannerObject.nextInt();
System.out.print("Enter value of third Integer: ");
int thirdInteger=scannerObject.nextInt();
System.out.println("---------- Output -----------");
System.out.println("Entered 1st Integer Value: " + firstInteger);
System.out.println("Entered 2nd Integer Value: " + secondInteger);
System.out.println("Entered 3rd Integer Value: " + thirdInteger);
}
}
Output:
% javac ScannerReadExample.java
% java ScannerReadExample
Enter value of first Integer: 5
Enter value of second Integer: 10
Enter value of third Integer: 15
---------- Output -----------
Entered 1st Integer Value: 5
Entered 2nd Integer Value: 10
Entered 3rd Integer Value: 15
More Posts related to Java,
- Get the current timestamp in Java
- Java Stream with Multiple Filters Example
- Java SE JDBC with Prepared Statement Parameterized Select Example
- Fix: UnsupportedClassVersionError: Unsupported major.minor version 63.0
- [Fix] Java Exception with Lambda - Cannot invoke because object is null
- 7 deadly java.lang.OutOfMemoryError in Java Programming
- How to Calculate the SHA Hash Value of a File in Java
- Java JDBC Connection with Database using SSL (https) URL
- How to Add/Subtract Days to the Current Date in Java
- Create Nested Directories using Java Code
- Spring Boot: JDBCTemplate BatchUpdate Update Query Example
- What is CA FE BA BE 00 00 00 3D in Java Class Bytecode
- Save Java Object as JSON file using Jackson Library
- Adding Custom ASCII Text Banner in Spring Boot Application
- [Fix] Java: Type argument cannot be of primitive type generics
- List of New Features in Java 11 (JEPs)
- Java: How to Add two Maps with example
- Java JDBC Transition Management using PreparedStatement Examples
- Understanding and Handling NullPointerException in Java: Tips and Tricks for Effective Debugging
- Steps of working with Stored Procedures using JDBCTemplate Spring Boot
- Java 8 java.util.Function and BiFunction Examples
- The Motivation Behind Generics in Java Programming
- Get Current Local Date and Time using Java 8 DateTime API
- Java: Convert Char to ASCII
- Deep Dive: Why avoid java.util.Date and Calendar Classes
More Posts:
- How to check installed docker version command - Docker
- How to Compare Strings in Bash Script - Bash
- Install Oh My Zsh on Ubuntu Docker complete steps - Ubuntu
- Run Gradle Build without test cases - Gradle
- How to shuffle lines randomly in Sublime Text - Sublime-Text
- How to wrap column text in SharePoint Online Modern List Grid View using JSON formatting - SharePoint
- How to Add Edit with Notepad++ Option to Windows 10 or 11 Right Click Menu Options - Windows-11
- iOS 14 Airpods Connected message everytime when the iPhone is unlocked - Apple