View Single Post
Old 04-09-2009, 11:50 PM   #20 (permalink)
Logarithms
Logarithms's Avatar
 
Banned

Join Date: Apr 2009

Posts: 41

Logarithms is on a distinguished road

Default Re: Reading a book about C#. (newbie question)

I am sorry for any confusion, but I don't know C#. I was just expressing my opinion from what I knew about Java. My "test" was simply a way of knowing if you knew how to take input from the keyboard and properly format the information with escapes like "\t" or "\n."

However, I can write it in Java.
Code:
import java.util.Scanner;
public class Main
{
  public static void main (String[] args)
  {
   Scanner input = new Scanner(System.in);
   String firstName;
   String lastName;
   String month;
   int day;
   int year;

   System.out.println("Enter your first name: ");
   firstName = input.nextLine();
   System.out.println("Enter your last name: ");
   lastName = input.nextLine();
   System.out.println("Enter the month you were born: ");
   month = input.nextLine();
   System.out.println("Enter the day you were born: ");
   day = input.nextInt();
   System.out.println("Enter the year you were born: ");
   year = input.nextInt();

   System.out.println(First Name\tLast Name\tDOB);
   System.out.println(========\t========\t===);
   System.out.println(firstName+"\t"+lastName+"\t"+month" "+day+", "+year);
   }
}

Logarithms is offline