From b67d6559de4a6c9a4e2a212f8aac41314278225c Mon Sep 17 00:00:00 2001 From: ericdouglas Date: Fri, 29 May 2015 11:40:31 -0300 Subject: [PATCH] Intro to CS MIT - Problem set 01 --- .../README.md | 15 +++++- .../src/00-problem-set.js | 47 +++++++++++++++++++ 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 computer-science/01-introduction-to-cs-and-programming-mit/src/00-problem-set.js diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/README.md b/computer-science/01-introduction-to-cs-and-programming-mit/README.md index 1e52f56..7a222d6 100644 --- a/computer-science/01-introduction-to-cs-and-programming-mit/README.md +++ b/computer-science/01-introduction-to-cs-and-programming-mit/README.md @@ -1 +1,14 @@ -# [Introduction to Computer Science and Programming](http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/) \ No newline at end of file +# [Introduction to Computer Science and Programming](http://ocw.mit.edu/courses/electrical-engineering-and-computer-science/6-00sc-introduction-to-computer-science-and-programming-spring-2011/) + +## Unit 1 + +- INTRODUCTION TO 6.00 ✔ +- CORE ELEMENTS OF A PROGRAM ✍ +- PROBLEM SOLVING +- MACHINE INTERPRETATION OF A PROGRAM +- OBJECTS IN PYTHON +- RECURSION +- DEBUGGING +- EFFICIENCY AND ORDER OF GROWTH +- MEMORY AND SEARCH METHODS +- QUIZ 1 \ No newline at end of file diff --git a/computer-science/01-introduction-to-cs-and-programming-mit/src/00-problem-set.js b/computer-science/01-introduction-to-cs-and-programming-mit/src/00-problem-set.js new file mode 100644 index 0000000..0995190 --- /dev/null +++ b/computer-science/01-introduction-to-cs-and-programming-mit/src/00-problem-set.js @@ -0,0 +1,47 @@ +/* + + Write a program that does the following in order: + + 1. Asks the user to enter his/her date of birth. + 2. Asks the user to enter his/her last name. + 3. Prints out the user’s last name and date of birth, in that order. + +*/ + +var answers = 0; + +process.stdin.resume(); + +console.log( 'What is your birth date?' ); +process.stdin.setEncoding( 'utf8' ); + +process.stdin.on( 'data', function( input ) { + + var birthDate = ''; + var lastName = ''; + + if ( answers === 0 ) { + + birthDate = input; + answers += 1; + + console.log( 'What is your last name?' ); + + } else if ( answers === 1 ) { + + lastName = input; + + console.log( + '================\n', + 'Birth date:', + birthDate, '\n', + 'Last Name:', + lastName, '\n', + 'Bye!' + ); + + process.exit(); + + } + +}); \ No newline at end of file