Docsity

Laboratory 2 : Syntax Errors and Variables | CS 010, Lab Reports of Computer Science

Toggle sidebar
bg1
CS 010 – Intro to Computer Science Fall - 2003
Lab 2: Syntax errors & Variables Week 2: 10/2 – 10/8
Part A: Write an algorithm (in English) for this problem definition:
You want to convert the number of days until Christmas to the number of hours until Christmas, the number of
minutes until Christmas, the number of seconds until Christmas and finally the number of months until Christmas. The
number of days should be provided by the user.
Have the TA check your algorithm.
Part B: Convert your algorithm to C++ code using integer variables. Your program should then output the number of hours
until Christmas, the number of minutes until Christmas, the number of seconds until Christmas, and the number of months
until Christmas (assume 1 month = 30 days) each on a separate line. Your output should look something like this:
Enter the number of days until Christmas:
10
There are 240 hours until Christmas.
There are 14400 minutes until Christmas.
There are 864000 seconds until Christmas.
There are 0 months until Christmas.
Now change the integer variables to double variables and rerun your program.
Demonstrate your program to the TA.
Part C: Find a partner that has completed Part A and B. Each partner should deliberately change their partner’s code to cause
a syntax error. Each time, you should recompile your own code, find the error and correct it. Keep a log of all errors and their
corrections. Some examples to use are:
Omit a semi-colon
Add a space just before “iostream” in the Include Directive
Omit any symbol
Omit and/or misspell a keyword
Etc.
Be creative!!
Show your error/correction log to the TA.
NOTES:
Every submission in this course (including this program, all assignments, lab work, quizzes & exams) must
include the following details at the top:
Name in the format Last name, first name
Last 4 digits of your student ID
Your UCR email address
Lecture section / Lab section (e.g. section 001/025)
In addition, for all lab-related submissions, include your lab id (in the form cs10xx)
pf2

Partial preview of the text

Download Laboratory 2 : Syntax Errors and Variables | CS 010 and more Lab Reports Computer Science in PDF only on Docsity!

CS 010 – Intro to Computer Science Fall - 2003

Lab 2: Syntax errors & Variables Week 2: 10/2 – 10/

Part A: Write an algorithm (in English) for this problem definition: You want to convert the number of days until Christmas to the number of hours until Christmas, the number of minutes until Christmas, the number of seconds until Christmas and finally the number of months until Christmas. The number of days should be provided by the user. Have the TA check your algorithm. Part B: Convert your algorithm to C++ code using integer variables. Your program should then output the number of hours until Christmas, the number of minutes until Christmas, the number of seconds until Christmas, and the number of months until Christmas (assume 1 month = 30 days) each on a separate line. Your output should look something like this: Enter the number of days until Christmas: 10 There are 240 hours until Christmas. There are 14400 minutes until Christmas. There are 864000 seconds until Christmas. There are 0 months until Christmas. Now change the integer variables to double variables and rerun your program. Demonstrate your program to the TA. Part C: Find a partner that has completed Part A and B. Each partner should deliberately change their partner’s code to cause a syntax error. Each time, you should recompile your own code, find the error and correct it. Keep a log of all errors and their corrections. Some examples to use are: Omit a semi-colon Add a space just before “iostream” in the Include Directive Omit any symbol Omit and/or misspell a keyword Etc. Be creative!! Show your error/correction log to the TA. NOTES: Every submission in this course (including this program, all assignments, lab work, quizzes & exams) must include the following details at the top: Name in the format Last name, first name Last 4 digits of your student ID

Your UCR email address

Lecture section / Lab section (e.g. section 001/025) In addition, for all lab-related submissions, include your lab id (in the form cs10xx)

After the first week you will lose points for failing to observe these instructions – in fact, if enough of this information is missing or illegible, we may not be able to assign you a grade, so double check every assignment before you turn it in.