5
CS10001: Computer Literacy – Lab Assignment #4 (D. Reed) 1 CS10001: Computer Literacy Lab Assignment #4 Lab Policies: Lab attendance is mandatory. You are given the opportunity to use the university’s resources to start and complete the assignment during the lab time. An electronic submission is required, so be sure to post your answers to the research.kent.edu server under your CS10001 folder. Please see the instructor if you have any questions about the lab assignment. Without a valid excuse, under emergency conditions, no late submission of this lab will be accepted. Goals: This is a survey of using different programming languages to develop the same program. The integrated development environments for each language will vary and some are more user-friendly than others. Additional topics pertaining to the program development life cycle, PDLC, will be included. Grading: This lab is worth 100 points and the breakdown of points follows: Attendance: 20 points Writing a C++ program: 20 points Writing a Python program: 20 points Writing a HTML Web Page: 20 points Writing an Alice Program: 20 points Writing a C++ Program: 1. Open the application for CS10051 from Start Programs CS10051. At the About dialog box, select Continue. Choose the C++ Compiler from the menu. 2. In the left side of the IDE, type the program that follows. Be sure to change “Joe Student” to your name. // Programmer: Joe Student // Program name: hello.cpp // Date written: April 9, 2009 #include<iostream.h> void main() { cout << "This is my first C++ program." << endl; cout << "C++ is a 3GL language." << endl; cout << "It uses a compiler." << endl; cout << "Hello, World!" << endl; }

CS10001: Computer Literacy Lab Assignment #4

  • Upload
    others

  • View
    3

  • Download
    1

Embed Size (px)

Citation preview

Page 1: CS10001: Computer Literacy Lab Assignment #4

CS10001: Computer Literacy – Lab Assignment #4 (D. Reed) 1

CS10001: Computer Literacy Lab Assignment #4

Lab Policies: Lab attendance is mandatory. You are given the opportunity to use the university’s resources to start and complete the assignment during the lab time. An electronic submission is required, so be sure to post your answers to the research.kent.edu server under your CS10001 folder. Please see the instructor if you have any questions about the lab assignment. Without a valid excuse, under emergency conditions, no late submission of this lab will be accepted. Goals: This is a survey of using different programming languages to develop the same program. The integrated development environments for each language will vary and some are more user-friendly than others. Additional topics pertaining to the program development life cycle, PDLC, will be included. Grading: This lab is worth 100 points and the breakdown of points follows:

Attendance: 20 points Writing a C++ program: 20 points Writing a Python program: 20 points Writing a HTML Web Page: 20 points Writing an Alice Program: 20 points

Writing a C++ Program:

1. Open the application for CS10051 from Start Programs CS10051. At the About dialog box, select Continue. Choose the C++ Compiler from the menu.

2. In the left side of the IDE, type the program that follows. Be sure to change “Joe Student” to your

name. // Programmer: Joe Student // Program name: hello.cpp // Date written: April 9, 2009 #include<iostream.h> void main() { cout << "This is my first C++ program." << endl; cout << "C++ is a 3GL language." << endl; cout << "It uses a compiler." << endl; cout << "Hello, World!" << endl; }

Page 2: CS10001: Computer Literacy Lab Assignment #4

CS10001: Computer Literacy – Lab Assignment #4 (D. Reed) 2

Writing a C++ Program – cont’d: 3. Save the program to the desktop of the local machine (File Save as) and name the file

hello.cpp. 4. From the menu bar, select Compiler Compile. A compiled version of the program will be

displayed in the right side of the IDE. If syntax errors occur, correct the program, save it, and then re-compile. If there were no syntax errors, an error-free compilation occurs.

5. Run the program by choosing Compiler Execute. From the virtual machine window, select

the option to Run. Use Prnt Scrn to take a screenshot and insert it in a Word document. Name the file cplusplus.doc and upload it to the research.kent.edu server (place it in your CS10001 folder). Be sure that the document is viewable through a browser.

6. Upload the hello.cpp file to the server also and place it in your CS10001 folder. Close the

CS10051 IDE and menu windows.

Writing a Python Program: 1. Open the Python application from Start Programs Python 2.6 IDLE (Python GUI). You

will be presented with a Python shell. A developer may use the shell’s command prompt (>>>) to test a code statement. The interpreter will check the statement for the correct syntax. To try this, hit enter after typing the following statement at the command prompt.

print “My name is ….” The output, which is enclosed in the quotes, is displayed in blue. To see how syntax errors are produced, try typing the statement again and misspell the command “print”; see the following: prin “My name is ….” A syntax error results and is printed in red. As part of the debugging process, the programmer would be responsible for evaluating the statement and making the necessary correction.

2. From the menu bar select File New Window to open a Python editor. In the editor, type in the

program that follows. Be sure to change “Joe Student” to your name.

# Programmer: Joe Student # Program name: hello.py # Date written: April 9, 2009 print "This is my first Python program." print "Python is a 3GL language." print "It uses an interpreter." print "Hello, World!"

3. Save the file to the local machine’s desktop and name it hello.py.

Page 3: CS10001: Computer Literacy Lab Assignment #4

CS10001: Computer Literacy – Lab Assignment #4 (D. Reed) 3

Writing a Python Program – cont’d: 4. From the menu bar, choose Run Run Module (F5). The program’s output will be displayed in

the Python shell window. Use Prnt Scrn to take a screenshot and insert it in a Word document. Name the file python.doc and upload it to the research.kent.edu server (place it in your CS10001 folder). Be sure that the document is viewable through a browser.

5. The IDE in Python provides a screen for viewing program output, but the operating system may

also be used to view results. To see how this works, go back to the Python program and insert some new lines of code (see the boxes).

# Programmer: Joe Student # Program name: hello.py # Date written: April 9, 2009 import os import time import sys print "This is my first Python program." print "Python is a 3GL language." print "It uses an interpreter." print "Hello, World!" time.sleep(2) os.system("cls") print "Goodbye!" time.sleep(4)

6. Save the program again and leave it on the desktop. Double-click the desktop file (hello.py) to let

the operating system run the program. 7. Upload the hello.py file to the server also and place it in your CS10001 folder. Close all of the

Python IDE windows.

Writing a HTML Web Page Program:

1. Unless you are using a HTML generator program, you will not encounter any particular IDE for Web page creation. All that is required is a text editor (Notepad) and a browser window.

2. Visit http://www.webmonkey.com/ and use the “Tutorials” tab at the top to select “Web Basics”.

Choose the link to “Make an HTML Document” and read this short summary about the common tags used in HTML.

3. Go back to the home page of Webmonkey (http://www.webmonkey.com/) by selecting the home

icon next to the “Tutorials” tab. Under the “Flash Cheat Sheet” information choose the link to the “HTML Color Charts”. Look at all the color shades and their respective hex code representations and pick two colors. One color will be used as a background color and the other color will be the color of the text.

Page 4: CS10001: Computer Literacy Lab Assignment #4

CS10001: Computer Literacy – Lab Assignment #4 (D. Reed) 4

Writing a HTML Web Page Program – cont’d:

4. Use Start Programs Accessories Notepad to open the text editor and type in the HTML code that follows. Be sure to change “Joe Student” to your name.

<html> <!-- Programmer: Joe Student --> <!-- Program name: hello.html --> <!-- Date written: April 9, 2009 --> <style type="text/css"> body {background: #7712ED} h1 {color: #FFFFFF; font-size: 24pt; font-family: arial} </style> <head><title>HTML Program Demo</title></head> <body> <h1>Hello, World!</h1> </body> </html>

5. Select File Save as and save the file to the local machine’s desktop with the name of

hello.html. Be sure to change the Save as Type to All Files.

6. Go to the desktop and notice the icon for the file (it should be associated with a browser). Double-click on the icon to view the Web page. You should see white text on a blue background.

7. Modify the program in the text editor by changing the background and text colors in the original

code. Replace #7712ED with your background color and replace #FFFFFF with your text color. Save the file and view it from the desktop. Change the colors if necessary, save the file, and refresh the browser view. Keep modifying the color combination until you are satisfied.

8. Update the code to include some paragraph lines using the tags <p> and </p>. Insert the lines

after the “Hello, World!” text and add the following: <p>Programmer: Your Name</p> <p>Date written: April 9, 2009</p>

9. Save the file and view the results through the browser. Close the Notepad application and upload hello.html directly to the research.kent.edu server. Place it in your CS10001 folder.

10. Close any open browser windows.

Page 5: CS10001: Computer Literacy Lab Assignment #4

CS10001: Computer Literacy – Lab Assignment #4 (D. Reed) 5

Writing an Alice Program: 1. Open the application for Alice from Start Programs Alice.

2. Create a program that displays 3D text with the value of “Hello, World!”. Use the background of

your choice, but make the color of the text purple. The default font should be used. 3. Insert code statements to handle spinning the text around the vertical axis twice. Precede the

code statements with comments about the programmer’s name, program name (hello.a2w), and date written. Test the program to ensure that it works.

4. Use Prnt Scrn to take a screenshot of the Alice program and insert it in a Word document.

Name the file alice.doc and upload it to the research.kent.edu server (place it in your CS10001 folder). Be sure that the document is viewable through a browser.

5. Close the Alice application, overriding any prompts to save the file.

Summary: Several files were created for this lab and all of them should be posted to your server account and placed inside the CS10001 folder. The files to be submitted are:

cplusplus.doc hello.cpp python.doc hello.py hello.html alice.doc