CS 112 Project 0: Getting Started
Objectives:
- Practice things we've learned in class.
Grading Rubric
This lab is worth 12 pts:
- 2 points for each of steps 3, 4, 5, 6, and 7.
- 1 point for having your name and user-name at the top of the answers.txt file.
- 1 point for naming your submission directory and file correctly.
- The project is due at midnight on Monday. You will receive a 10% per day penalty for lateness.
Step 1.
Create a new project in Eclipse called proj0. (Note: it is not called proj 0 or Proj0 or
Project0 or Project 0).
Create a C++ file in the project called main.cpp.
Step 2.
In your project, create a second file -- a text file -- called answers.txt. In that file, put your name,
userid (e.g., vtn2), the date, and the project number.
Step 3.
In main.cpp, in main(), create a constant unsigned integer called BIG_NUMBER, initialized to 10 million.
Then, create a variable of type string and initialize it to your name. (Note: you will have to
#include <string> to make this work.)
Then, create a variable of type char and initialize it to the first letter of your last name.
Then, create a variable of type double and initialize it to the value 3.1415.
Then, create a variable of type bool and initialize it to false.
Then, create a variable of type long and initialize it to 0.
Compile and run your code. NOTE: you'll get warnings about unused variables. Ignore them.
Put a header line in your answers.txt file like:
Step 3. --------------------------
Paste the code you wrote above into your answers.txt file under that header line. Put a header line like
this above each of your subsequent "pastes" into answers.txt.
Step 4.
Write code to print out the locations of each of the variables, in hexadecimal. Run your program,
and put your code and the output of your code into your answers.txt file.
Note: if you get a weird answer for when you print out the location of the char variable,
don't worry about it. Just go on.
Step 5.
Comment out the body of main() so far.
Write code to initialize a variable of type int to the value 37.
Write code to print out the value of that variable in decimal, octal, and hexadecimal.
Put the results of your code into your answers.txt file.
Step 6.
Erase the contents of main().
Create a variable that will hold an array of 20 float.
Write a line of code to print out the total size of that variable. Note that you might find sizeof
useful.
Put your code and the results of your code into your answers.txt file.
Step 7.
Create a variable that is a pointer to a float, and initialize it to refer to the location of the 7th item in
the array you just created (i.e., the location of the item at index 7).
Write code to initialize that location to the value 17.771.
Write code to print out the value at index 7 of the array.
Write code to print out the value at the location the pointer variable points to.
Copy your code for this step and your output into your answers.txt file.
Submit
Submit a fully functional electronic copy of your project folder
(including all source files, your txt files, and any test files they use),
to a folder named
/home/cs/112/current/yourUserName/proj0
(replacing yourUserName with your actual user-name).
If you need a reminder on how to do this submission, read on:
The folder /home/cs/112/current should contain a folder with your user-name.
You can check by typing this command into a terminal window:
$ ls /home/cs/112/current
Each week's lab and project must be (separately) copied to your folder,
so that the grader can grade it.
If your lab is not copied to your folder within
/home/cs/112/current, the grader will not be able to find it,
and you will receive a zero!
To illustrate, suppose that your user-name is abc1,
that you are currently in your home folder,
that your Eclipse workspace is named cs112,
that your cs112 folder is within your home folder,
and that your proj0 folder is inside your cs112 folder
(i.e., /home/abc1/cs112/proj0).
Then you should enter:
$ cd cs112
to change directory to your workspace
-- the folder "above" your proj0 folder.
Then enter:
$ ls
to view the contents of your workspace.
At this point, you should see folders for
last week's lab (lab0), and this week's project (proj0).
Then enter:
$ cp -r proj0 /home/cs/112/current/abc1
where you replace abc1 with your user-name.
The cp -r command will recursively copy proj0
and all of its subfolders into your folder inside /home/cs/112/current/.
You can check that this worked by listing the contents of your folder:
$ ls /home/cs/112/current/abc1
proj0
and then verifying that your folder contains a copy of the today's files:
$ ls /home/cs/112/current/abc1/proj0
... files for proj0 should appear ...
We will be using these same commands to submit our labs and
projects each week for the rest of the semester,
so you should record them somewhere that you can easily find them
(or maybe bookmark this page).
When your folder within current contains a copy of your project work,
you are all done.
Congratulations!
The grader will grade your submission according to this rubric:
-
Your name and info at the top of the file: 2
-
Answers to the questions: 15 (3 pts each x 5 steps that required answers)
-
Total 17
Our grader will grade this electronic submission,
and provide feedback on any issues she or he finds with it
in the Moodle gradebook entry for this project.
CS >
112 >
Projects >
00
This page maintained by
Victor Norman.