Quick Links to Application questions (with solutions)!

C++.

Java.

Sunday, January 17, 2010

Words - Sentence (with user input) code

import java.util.Scanner;

class bananas
{
public static void main(String args[])
{
Scanner eggs = new Scanner(System.in); //eggs is just a word I picked.
System.out.println("Type words and system will show you what you typed in another line.");
System.out.println(eggs.nextLine()); //System gets eggs(scanner) and ensures they are words. (1) Eggs gets the input.[in] (2) System prints it out.[out]
System.out.println("Type numbers and system will show you what you typed in another line.");
System.out.println(eggs.nextInt()); //System gets eggs(scanner) and ensures they are numbers. (1) Eggs gets the input.[in] (2) System prints it out.[out]
}
}

No comments:

Post a Comment