Lesson 3 of 34

Scanner மூலம் Input பெறுதல்Reading Input with Scanner

8 min 20 XP

User-இடமிருந்து மதிப்புகளைப் பெற Scanner பயன்படுத்துகிறோம். முதலில் import java.util.Scanner; என்று எழுத வேண்டும். Run செய்வதற்கு முன் Input box-ல் மதிப்புகளை type செய்யுங்கள்.

We read values from the user with a Scanner. First write import java.util.Scanner; at the top. Type the values in the Input box before you press Run.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

nextInt() ஒரு முழு எண், nextDouble() ஒரு தசம எண், next() ஒரு சொல் (space வரை), nextLine() முழு வரியையும் படிக்கும். Space அல்லது புதிய வரியால் பிரிக்கப்பட்ட மதிப்புகளை ஒவ்வொன்றாகப் படிக்கலாம்.

nextInt() reads a whole number, nextDouble() a decimal, next() one word (up to a space) and nextLine() a whole line. Values separated by spaces or new lines are read one at a time.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

"Sum = " + a + b என்று எழுதினால் 1230 என்று வரும்! முதலில் கணக்கிட (a + b) என்று bracket போடுங்கள்.

Writing "Sum = " + a + b prints 1230! Put (a + b) in brackets so the numbers are added first.

Challenge

+20 XP

இரண்டு முழு எண்களைப் படித்து அவற்றின் பெருக்கல் தொகையை (product) print செய்யுங்கள். Input: 6 7 → Output: 42

Read two whole numbers and print their product. Input: 6 7 → Output: 42

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.