home • strose • rpi • nysed • g-revisions
CSCI-1100-01
Computer Science I
MTWR 10:00-11:50am
Lally 104
Assistant Professor of Computer Science
The College of Saint Rose
Adjunct Professor of Computer Science
Rensselaer Polytechnic Institute
DUE: Tuesday 6/30
For this (and all) labs, you may use Microsoft Visual Studio, which is available at the VCC. Or you may use Cygwin, Linux, or a campus Unix machine (via ssh or SecureCRT). If you need help installing or setting up this software, just ask and we'll figure it out.
// Lab #1
//
// Name: your-name-here
// Date: today's-date-here
#include <iostream>
using namespace std;
int main()
{
cout << "Computer's are dumb until they're told what to do." << endl;
return 0;
}
$ g++ -Wall filename.cpp
WINDOWS: Computer's are dumb until they're told what to do. Press any key to continue . . . CYGWIN/LINUX: Computer's are dumb until they're told what to do.
David Goldschmidt Wednesday, May 2, 1973 French toast This summer, I'm trying to publish a children's book.
10001000 ==> unsigned-base-10-answer 11111110 ==> unsigned-base-10-answer 1110110010001000 ==> unsigned-base-10-answer 10001000 ==> two's-complement-base-10-answer 11111110 ==> two's-complement-base-10-answer 1110110010001000 ==> two's-complement-base-10-answer
D
A
V
I
D
\D\
\A\
\V\
\I\
\D\
Here's a great quote by Ernest Hemingway from THE OLD MAN AND THE SEA: "'I may not be as strong as I think,' the old man said. 'But I know many tricks and I have resolution.'" Abraham Lincoln said: "Four score and seven years ago, ..."
DUE: Thursday 7/2
This program converts a Fahrenheit temperature to Centigrade. Please enter the Fahrenheit temperature: 212 ==> 212 degrees Fahrenheit is equivalent to 100 degrees Celsius Hey, that's the boiling point of pure water!
This program converts temperature values. Would you like to enter a temperature as Fahrenheit (f) or Centigrade (c)? c Please enter the Centigrade temperature: 100 ==> 100 degrees Celsius is equivalent to 212 degrees Fahrenheit Hey, that's the boiling point of pure water!or
This program converts temperature values. Would you like to enter a temperature as Fahrenheit (f) or Centigrade (c)? q I don't know what 'q' means. Go away.
DUE: Monday 7/6
command? add 400 500 400 + 500 = 900 command? add 400 500 600 700 400 + 500 + 600 + 700 = 2200 command? subtract 500 400 500 - 400 = 100 command? multiply 600 0.5 0.5 600 * 0.5 * 0.5 = 150 command? divide 700 7 700 / 7 = 100 command? sqrt 25 sqrt( 25 ) = 5 command? sqrt -10 ERROR!
DUE: Wednesday 7/8
Enter word: draw The word you entered is "draw" Your word in reverse is "ward" Your word contains 4 characters Your word contains 0 UPPERCASE letters Your word contains 4 lowercase letters Your word contains 1 vowel Your word contains 0 digits
Enter word: Day7 The word you entered is "Day7" Your word in reverse is "7yaD" Your word contains 4 characters Your word contains 1 UPPERCASE letter Your word contains 2 lowercase letters Your word contains 1 vowel Your word contains 1 digit
Enter word: refer The word you entered is "refer" Your word in reverse is "refer" Your word is a palindrome Your word contains 5 characters Your word contains 0 UPPERCASE letters Your word contains 5 lowercase letters Your word contains 2 vowels Your word contains 0 digits
Now type an entire sentence: Why does it say paper jam when there is no paper jam? You typed the following sentence: "Why does it say paper jam when there is no paper jam?" Your sentence contains 53 characters Your sentence contains 11 spaces
Now type an entire sentence: Murder for a jar of red rum. You typed the following sentence: "Murder for a jar of red rum" Your sentence contains 28 characters Your sentence contains 6 spaces Your sentence is a palindrome!
DUE: Wednesday 7/15
Please enter six grades in the range [0.0,10.0]. Grade #1: 8.5 Grade #2: 7.5 Grade #3: 9 Grade #4: 19.9 ERROR: Invalid grade. Please try again. Grade #4: 9.9 Grade #5: 6.5 Grade #6: -87.5 ERROR: Invalid grade. Please try again. Grade #6: 8.5 Thank you.
The lowest grade entered was 6.5 (not very good). The highest grade entered was 9.9 (nice work).
The average is 8.31667 (sounds average to me). Drop the lowest grade (6.5) and the average is 8.68 (better).
Grades in reverse order are 8.5 6.5 9.9 9 7.5 8.5
Please enter grades in the range [0.0,10.0]. Enter -1.0 to end. Grade #1: 8.5 Grade #2: 7.5 Grade #3: 9 Grade #4: 19.9 ERROR: Invalid grade. Please try again. Grade #4: 9.9 Grade #5: 6.5 Grade #6: -87.5 ERROR: Invalid grade. Please try again. Grade #6: 8.5 Grade #7: 9.4 Grade #8: -1.0 Thank you. The lowest grade entered was 6.5 (not very good). The highest grade entered was 9.9 (nice work). The average is 8.47143 (sounds average to me). Drop the lowest grade (6.5) and the average is 8.8 (better). Grades in reverse order are 9.4 8.5 6.5 9.9 9 7.5 8.5
DUE: Thursday 7/16
Successfully read 74080 data points from the "die-rolls.txt" data file.
Distribution for 74080 data points (each '>' counts as 500 rolls): 6: >>>>>>>>>>>>>>>>>>>>>>>> (11879) 5: >>>>>>>>>>>>>>>>>>>>>>>>>> (12981) 4: >>>>>>>>>>>>>>>>>>>>>>>> (11990) 3: >>>>>>>>>>>>>>>>>>>>>>>>>> (12947) 2: >>>>>>>>>>>>>>>>>>>>>>>>> (12381) 1: >>>>>>>>>>>>>>>>>>>>>>>> (11902)
DUE: Tuesday 7/21
Please enter the coordinates of point #1: 5.8 9.8 Please enter the coordinates of point #2: 2 14.5 You entered: (5.8, 9.8) and (2, 14.5)
The distance between these two points is: 6.04401
The slope of this line is: -1.23684
The equation of the line containing both of these points is:
y = -1.23684x + 16.9737
Okay, enter an x coordinate: 87.8
y = -91.6211
Please enter the coordinates of point #3: 87.8 -91.6211 Yes, that point is on the line!
Please enter the coordinates of point #1: 18.8 12
Please enter the coordinates of point #2: 14.2 -7
You entered: (18.8, 12) and (14.2, -7)
The distance between these two points is: 19.5489
The slope of this line is: 4.13043
The equation of the line containing both of these points is:
y = 4.13043x - 65.6522
Okay, enter an x coordinate: 582.5
y = 2340.33
Please enter the coordinates of point #3: 0.5 300
No, that point is not on the line.
DUE: Thursday 7/23
Write a C++ program that works with both functions and arrays.
David John Mary Dave Frank Jon Mary-Anne Francis Brett Paula Jenna
int read_names( string filename, string names[], int max_names );
Successfully read 11 names
NAMES: David John Mary Dave Frank Jon Mary-Anne Francis Brett Paula Jenna
Please enter a name to search for: Frank Yes, Frank is on the list. Please enter a name to search for: Mildred Nope, Mildred is not on the list.
Please enter a name prefix to search for: J FOUND: John, Jon, Jenna Please enter a name prefix to search for: Jo FOUND: John, Jon Please enter a name prefix to search for: Dav FOUND: David, Dave Please enter a name prefix to search for: dav FOUND: David, Dave Please enter a name prefix to search for: Geo FOUND: (none)
DUE: Thursday 7/30
Write a C++ program that uses struct, arrays, and functions to simulate an online product catalog (be the next amazon.com!).
Successfully read in 17 products.
Here are the products to choose from: [ID:1200] notebook $1.99+tax [ID:1201] pencil $0.25+tax [ID:1202] pen $0.89+tax [ID:1203] backpack $12.50+tax [ID:2000] t-shirt $11.95 (no tax) [ID:2001] jeans $46.95 (no tax) ...
Enter the ID of the product you'd like to purchase: 1201 Great, how many "pencil" items would you like? 10 Okay, the cost will be: $2.50+tax Enter the ID of the product you'd like to purchase: 2000 Great, how many "t-shirt" items would you like? 2 Okay, the cost will be: $23.90 (no tax) ...
Enter the ID of the product you'd like to purchase: 0 You ordered the following: pencil (10) $2.50+tax t-shirt (2) $23.90 (no tax) Your total without tax is: $26.40 Your total with tax is: $26.61 And shipping is always free. :-) Thank you for your order!
DUE: Monday 8/3
Write a C++ program that uses functions to both sort and search an array of elements.
Successfully read in 21 names.
For each array position 0 through length-1: a. Find the name closest to "A" in the array from the current position to the end b. Swap name at current position with name closest to "A" found In other words, swap the first name into its correct position, then swap the second name into its correct position, then swap the third name into its correct position, etc.
Successfully sorted the list of names: Brett Dave David Deanna Edie Francis Frank Franklin George Helen Hubert Jackie Jenna John John Jon Lois Luke Mary Mary-Anne Paula
Enter a name to search for: Deanna Found Deanna in the list. Enter a name to search for: Greg Sorry, Greg is not in the list.