Source of MyProg.java


  1: import java.util.Scanner;

  3: /**
  4:  * Reads a number and a word from the user,
  5:  * then echoes them back.
  6:  *
  7:  * @author Mark Young (A00000000)
  8:  */
  9: public class MyProg {

 11:     public static void main(String[] args) {
 12:         // create variables
 13:         Scanner kbd = new Scanner(System.in);
 14:         double x;
 15:         String w;

 17:         // introduce your self
 18:         System.out.println("\n\n"
 19:             + "It's just a program. Go with it.\n");

 21:         // read a number
 22:         System.out.print("Enter a number: ");
 23:         x = kbd.nextDouble();
 24:         kbd.nextLine();

 26:         // read a word
 27:         System.out.print("Enter a word: ");
 28:         w = kbd.next();
 29:         kbd.nextLine();

 31:         // echo them back
 32:         System.out.println("\nYou entered " + x + " " + w + "s.\n");
 33:     }

 35: }