slides-4

slides-4 - 1 Data Structures - CSCI 102 Copyright William...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1 Data Structures - CSCI 102 Copyright William C. Cheng Housekeeping (Lecture 5 - 1/25/2011) Lab #2 (Streams) due this week during your lab session HW1 (Video Game Database) due next Monday night Ive added a paragraph to make sure you are handling "validation" properly Lab #3 (Classes) posted To be done next week during your lab session If validation failed, should try again A design doc is required before you can start your lab Must read Purchase Date into a string first See the "[BC: paragraph added 1/23/2011]" paragraph in spec Basically, if the user roll his/her hands on the keyboard or sits on the keyboard, you need to print out reasonable error messages 2) 3) 1) Questions? 2 Data Structures - CSCI 102 Copyright William C. Cheng Housekeeping (Lecture 5 - 1/25/2011) Class Google Group Lecture 4 remaining issues Vector resize() member function I posted something (about Lecture 4) there last Friday If you did not see my posting, that means that you are not a member of the class Google Group You must be on the class Google Group because all important announcements will be posted there I think I forgot to mention that a vector has no holes Slides 19 and 20 were both correct The wording there may be confusing, may be slide 19 should also say "2nd prompt skipped" 3 Data Structures - CSCI 102 Copyright William C. Cheng CS102 Extra Slides Bill Cheng http://merlot.usc.edu/cs102-s11 4 Data Structures - CSCI 102 Copyright William C. Cheng manipulators.cpp /* * 1) Demonstrate how to use C++ manipulators. * 2) Create an array of strings of product names, "books", * "toys", ... * 3) Create an array of doubls of product prices, 20.55, * 23.53, ... * 4) Left-align products in a field of 20 characters each * 5) Right-align prices in a field of 10 characters each * 6) Print 30 = characters * 7) For each product name and price, print a line with a * left-aligned name and right -aligned price. */ 5 Data Structures - CSCI 102 Copyright William C. Cheng manipulators.cpp #include <iostream> #include <string> #include <iomanip> using namespace std; int main() { string products[5] = { string("Books"), string("Wristwatches"), string("Toys"), string("Shoes"), string("Plates")}; double prices[5] = { 20.55, 23.53, 33.95, 111.22, 1000}; cout << setw(20) << left << "Products"; cout << setw(10) << right << "Price" << endl; cout << setw(30) << setfill(=) << "" << endl; cout << setfill( ); for(int i=0; i < 5; i++) { cout << setw(20) << left << products[i]; cout << setprecision(2) << fixed << setw(10) << right << prices[i]; cout << endl; } } 6 Data Structures - CSCI 102 Copyright William C. Cheng streams.cpp /* * 1) Demonstrate the differences between stdout & stderr....
View Full Document

This note was uploaded on 02/17/2011 for the course CSI 102 taught by Professor Billcheng during the Spring '11 term at USC.

Page1 / 23

slides-4 - 1 Data Structures - CSCI 102 Copyright William...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online