Sunday, June 1, 2014

IDEONE Java Basics 106 – Getting Inputs

---
IDEONE Java Basics 106 – Getting Inputs

PREREQUISITE

This tutorial uses the online compiler IDEone (www.ideone.com ).
IDEone gives you few benefits:
1) Zero setup. You just need Internet Connection and a modern Web Browser.
2) Online storage. You can refer back to the codes at later time.
3) Public codes available. You can also see how others write codes and learn from them as well.
4) Online Learning. You can ask a companion at remote location to help edit the codes or review your codes for improvements or troubleshooting algorithms.

STEPS

1) Start with the basic template

Clone the code above. (Click the Fork button).

2) Edit the codes.

2-1) Add:
a) A Scanner library import declaration statement (in the import declaration section).

import java.util.Scanner;
b) A Scanner object declaration statement (in the main method)

                Scanner user_input = new Scanner( System.in );
c) A String variable declaration statement (in the main method)

                String first_name;
d) An input request output statement (in the main method)

                System.out.print("Enter your first name: ");
e) A String input statement (in the main method)

                first_name = user_input.next( );
f) A String output statement (in the main method)

                System.out.println("You are " + first_name);
2-2) Run.

3) Further Edits

Task: Write codes to achieve the following outcome.
Hint: Use a variable full_name to combine the first name and family name.

REFERENCE

---

No comments:

Post a Comment