Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.io.File;
- import java.io.PrintStream;
- import java.io.FileNotFoundException;
- class EasyChallenge1
- {
- public static void main(String[] args) throws FileNotFoundException
- {
- Scanner input = new Scanner(System.in);
- System.out.println("What's your name?");
- String name = input.next();
- System.out.println("What's your age?");
- int age = input.nextInt();
- System.out.println("What's your reddit username?");
- String username = input.next();
- System.out.println("Your name is " + name + ", you're " + age + " years old, and your username is " + username + ".");
- System.out.println("Would you like me to create a file that stores this valuable information? y/n");
- String ExtraCredit = input.next();
- char ec = ExtraCredit.charAt(0);
- if (ec == 'y')
- {
- PrintStream output = new PrintStream(new File("Valuable_data.txt"));
- output.printf("Your name is " + name + ", you're " + age + " years old, and your username is " + username + ". Don't forget!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement