Advertisement
Guest User

EasyChallenge1

a guest
Feb 16th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.06 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.io.File;
  3. import java.io.PrintStream;
  4. import java.io.FileNotFoundException;
  5.  
  6. class EasyChallenge1
  7. {
  8.   public static void main(String[] args) throws FileNotFoundException
  9.   {
  10.     Scanner input = new Scanner(System.in);
  11.     System.out.println("What's your name?");
  12.     String name = input.next();
  13.     System.out.println("What's your age?");
  14.     int age = input.nextInt();
  15.     System.out.println("What's your reddit username?");
  16.     String username = input.next();
  17.     System.out.println("Your name is " + name + ", you're " + age + " years old, and your username is " + username + ".");
  18.    
  19.     System.out.println("Would you like me to create a file that stores this valuable information? y/n");
  20.     String ExtraCredit = input.next();
  21.     char ec = ExtraCredit.charAt(0);
  22.     if (ec == 'y')
  23.     {
  24.       PrintStream output = new PrintStream(new File("Valuable_data.txt"));
  25.       output.printf("Your name is " + name + ", you're " + age + " years old, and your username is " + username + ". Don't forget!");      
  26.     }
  27.   }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement