CSE 459.22     LAB1

 

*************************************
Assigned: 9/27/2005

Due: 10/11/2005 11:59pm

*************************************


Goals

Points

      This lab is worth 100 points.

Steps

I. INTRODUCTION AND SETUP

        -To login to Windows machines on a Lab PC:

  1. Momentarily press and hold the <control>, <alt>, and <delete> keys simultaneously. This will cause Windows to prompt you for your account information.

  2. Click inside the User name box and type the username that was provided to you by your instructor.

  3. Click inside the Password box and type your password. Your default password is the last four digits of your SSN followed by your first and last initials, followed by an exclamation point ('!') (e.g., Jane Smith's password would be something like 6789js!). Note: your default password is all lower-case!

  4. Make sure that CSE has been selected in the Log on to box, then click on the OK button to complete the process of login to Windows on the PC you're sitting at.

  5. On your first login, the system will prompt you to change your password

  6. In the future, press ctrl, alt and delete keys simultaneously and click on the Change Password button to change your password.

        -To login to Sun server from Windows machines on a Lab PC:

  1. After logging on to the windows machines, click on the stdsun icon (Blue X symbol) on the desktop.

  2. When you see the "login:" prompt, type in your username that was provided to you by your instructor and hit return.

  3. At the "password:" prompt, type in the last four digits of your social security number, followed by your first and last initial in lower case. For example, "5670bd". This is your default password.

  4. On your first login, the system will prompt you to change your password.

  5. In future, you can use the yppasswd command to change your password. Make sure that you remember your new password.

  6. Open an xterm Window in the UNIX environment, and you will see the following prompt
           /~~~~~~/username/ >
     Now, you are ready to play with the Unix system!

     NOTE:   If you are facing any problems in this regard, i.e. not knowing your login names or the default password, please contact the help desk at 292-6542 (SOC Lab DL 894).  

-   You can also ssh to stdsun.cse.ohio-state.edu  from other machines to work.

II. FOR YOUR INFORMATION

·        Remember to click on the title bar to activate the window you want to work in.

·        Remember, this system is case-sensitive.

·        Recommend you to create a new directory with name “cse459”, which can help to organize all your files for this class in one place.

mkdir cse459  <return>

cd cse459  <return>

·        The UNIX command man will tell you about a specific command.  For example, man mkdir will give the description of Unix command mkdir.

·        Some important UNIX commands:

1.    ls -l             list files
2.    cp               copy files
3.    more          display file contents on screen
4.    mv              move/rename files
5.    rm              remove files
6.    mkdir         make directory
7.    cd               change directory
8.    rmdir          remove directory
9.    lp                print command
10.  emacs         invokes the Emacs editor

·        At the prompt, the up arrow key brings up previously typed commands in reverse order; the down arrow key brings up previously typed commands in forward order.
   

III. DESCRIPTION OF THE ASSIGNMENT  

·        Your main() program should give the user a menu to choose from, as shown below.

I.   Enter a date
Q. Quit

Your program should proceed based on the user’s choice.

a) If the user chooses I (Input),
      read a date from the keyboard as mm/dd/yy;
      convert it to the output format if input is right, otherwise, give error message;
      return to the main menu and wait for user to choose the next action;
b) If the user chooses Q(quit), exit from the program.

·        Specification of Input and Output :

·        The correct input format is:

mm/dd/yy,

for example: 01/01/01.

·        The correct output format is:

mm/dd/yyyy,

where month and day do not need to be zero filled. An example could be 1/1/2001.

·        Assume we are interested only in years between 1950 and 2049, a Y2K correction is necessary for a 2-digit year, .i.e. if (year < 50) year += 2000; else if (year < 100) year += 1900.

·        If the input is not in correct format, your program needs to display an error message. For example, if 1/1/01 has been entered as a date by the user, the following error message will be given.

Invalid date format: 1/1/01 

Assume that the user enters only digits (i.e, you do not have to check for errors in input such as 1a/TY/2#)

·        Hint: you can use functions strtok and atoi from the C library to parse the input and extract month, day and year.

·        You don't need to handle invalid date, such as 09/50/01.  We will take care of that in the following labs.

·        The following labs will base on the date class in lab1. Try to get this lab working !

·        Save your program as lab1.cpp and compile it with g++ by entering the following command in the xterm window:

g++ -o lab1  lab1.cpp  <return>

Remove all compilation errors and warning messages before running the program.  Recompile each time you make a change to the program. By finishing, your program should compile and return to the prompt without displaying any error messages.

·        Run your program by entering the following command in the xterm window:

lab1 <return>

Test your program with several cases you may think of, such as "1/1/01", "01012001", "01/01/50", "12/12/01". It should comply with the specifications given above.


Here is a sample interaction between a user and the program:


(I) Enter a date
(Q) Quit

I <return>

Enter the starting date <mm/dd/yy> => 1/1/01 <return>
Invalid date format: 1/1/01

(I) Enter a date
(Q) Quit

I <return>

Enter the starting date <mm/dd/yy> => 01012001 <return>
Invalid date format: 01012001

(I) Enter a date
(Q) Quit

I <return>

Enter the starting date <mm/dd/yy> => 01/01/50 <return>
The date is 1/1/1950

(I) Enter a date
(Q) Quit

I <return>

Enter the starting date <mm/dd/yy> => 12/12/01 <return>
The date is 12/12/2001 

(I) Enter a date
(Q) Quit

Q <return> 

·      You SHOULD also test your program using a script similar to the sample grading script 

Submission 

When you finish with the lab, you need to turn it in for grading. The submit command submits your lab electronically. You MUST use the submit command to turn in your labs. The format of submit command is as follows:

submit classname labname files-to-submit

where,

classname is the name of the CIS 459.22 section that you are enrolled in. Your classname is c459.22ab .

labname is the lab you are working on (lab1, lab2, etc.). For this lab, labname is lab1 .

files-to-submit is a list of the files that make up the lab. For now, it only contains lab1.cpp .

NOTE: 

1. All of the files in a lab MUST be submitted using one command. If you use two submit commands, the second one ERASES the files from the first submission. So, make sure you always submit the entire set of files using one command.

2. Each submit command MUST be entered on one line without pressing Enter. If the line you are entering is too long, it wraps onto the next line.

3. Your programs MUST be submitted in source code form. Make sure that you submit the *.cpp files. Do NOT submit the object files (*.o) and/or the executable. If you submit the object code/executable and not the source code, your lab submission will be considered invalid.

4. Your code SHOULD compile and run on CSE department server stdsun.cse.ohio-state.edu, and it is YOUR responsibility to ensure that if you develop the code using other systems.

Submitting Lab1

            To submit your lab for grading, use the following command from the directory which contains your lab1.cpp file:

                        submit c459.22ab lab1 lab1.cpp