Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * DESCRIPTION:
- create a program that will ask the users name, age, and reddit username. have it tell them the information back, in the format:
- your name is (blank), you are (blank) years old, and your username is (blank)
- for extra credit, have the program log this information in a file to be accessed later.
- */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace First_Easy
- {
- class Program
- {
- static void Main(string[] args)
- {
- string name;
- int age;
- string reddit;
- //get name from user
- Console.Write("Enter your name: ");
- name = Console.ReadLine();
- Console.WriteLine();
- //get age from user
- string testAge;
- do
- {
- Console.Write("Enter your age: ");
- testAge = Console.ReadLine();
- Console.WriteLine();
- } while (!int.TryParse(testAge, out age));
- //get reddit name from user
- Console.Write("Enter your reddit username: ");
- reddit = Console.ReadLine();
- Console.WriteLine(Environment.NewLine);
- //Print the info on screen
- Console.WriteLine("your name is {0}, you are {1} years old, and your username is {2}", name, age, reddit);
- Console.ReadKey();
- //ninja add to file to hack this user later
- string secretLogFile = Environment.GetEnvironmentVariable("appdata");
- secretLogFile = System.IO.Path.Combine(secretLogFile, "redditProgramming");
- if (!System.IO.Directory.Exists(secretLogFile)) System.IO.Directory.CreateDirectory(secretLogFile);
- secretLogFile = System.IO.Path.Combine(secretLogFile, "first_easy.csv");
- string logInfo = string.Format("\"{1}\";{2};\"{3}\"{0}", Environment.NewLine, name, age, reddit);
- System.IO.File.AppendAllText(secretLogFile, logInfo);
- }
- }
- }
Add Comment
Please, Sign In to add comment