Intro to CS MIT - Problem set 01

This commit is contained in:
ericdouglas 2015-05-29 11:40:31 -03:00
parent 7a8a95fbb9
commit b67d6559de
2 changed files with 61 additions and 1 deletions

View File

@ -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/)
# [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

View File

@ -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 users 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();
}
});