6 Pages

exam1Solution

Course: CGS 3464, Fall 2008
School: University of Florida
Rating:
 
 
 
 
 

Word Count: 621

Document Preview

3464 CGS - Programming using C++ Spring 2005 Exam 1 Instructions 1. Do not begin writing until you are told to do so. 2. Read all the instructions here carefully. Failure to do so will result in loss of points. 3. You have 50 mins to answer the questions. 4. Answer all questions. 5. There are 5 sheets in this exam (including this one). 6. There are three questions in this test. 7. This test is closed book, closed...

Register Now

Unformatted Document Excerpt

Coursehero >> Florida >> University of Florida >> CGS 3464

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
3464 CGS - Programming using C++ Spring 2005 Exam 1 Instructions 1. Do not begin writing until you are told to do so. 2. Read all the instructions here carefully. Failure to do so will result in loss of points. 3. You have 50 mins to answer the questions. 4. Answer all questions. 5. There are 5 sheets in this exam (including this one). 6. There are three questions in this test. 7. This test is closed book, closed notes. 8. You have to write your answers on this test. You can write on both sides of the sheets. 9. Read and sign the academic honesty statement. Name: Key CourseTool ID: On my honor, I have neither given nor received unauthorized aid in this examination. Signature: 1 1. (5 points) Answer all of the following questions. (a) (0.5 points) What is the value of f after the second statement? double f, c = 20.0; f = (9/5)*c + 32; (b) (1.5 points) What is the output of the following code snippet? (If you feel that the code will result in a compile-time or run-time error, state why). int i=0,j=5; if (j || (j/i > 5)) cout << 2*j << " "; (c) (3 points) State three main concepts in object oriented programming. Answers: (a) The value of f is 52.0. (b) The output is: 10 Hint: Short-circuit evaluation. (c) Three main concepts in object oriented programming: Data encapsulation, Information hiding and data abstraction. 2 2. (10 points) Write a program which denes a structure Statistics which contains three members, one each for sum, mean and the maximum value (all doubles). You should also write three functions: Statistics CollectStats(vector<double> vec); void DisplayStats(Statistics stat); int main() CollectStats() takes a vector of doubles and returns the statistics for the vector. DisplayStats() displays the statistics. For example: Sum = 55.0 Mean = 5.5 Max = 10.55 main() declares a vector and gets the elements from the user (the user inputs 0 (zero) to mark end of input). It then computes the statistics and displays the results. Solution: #include<iostream> #include<vector> using namespace std; struct { double double double }; Statistics sum; mean; max; Statistics CollectStats(vector<double> { vec) Statistics stats = {0,0,0); stats.max = vec[0]; for (int i=0;i < vec.size(); i++) { stats.sum += vec[i]; if (vec[i] > stats.max) stats.max = vec[i]; } stats.mean = stats.sum/vec.size(); return stats; } void DisplayStats(Statistics stat) { cout << "Sum = " << stat.sum << endl << "Mean = " << stat.mean << endl << "Max = " << stat.max << endl; } int main() 3 { vector<double> arr; double input = 0; do { cout << "Enter a number (0 to stop):"; cin >> input; if (0 != input) arr.push_back(input); } while (0 != input); Statistics myStats = CollectStats(arr); DisplayStats(myStats); return 0; } 4 3. (10 points) You are given the following class (along with its implementation): class Rupees { public: Rupees(); //Initializes rupees = 0 and paise = 0 Rupees(int r, int p); //Initialises rupees to r and paise to p double GetMoney(); // returns paise/100.0 + rupees int GetR(); //returns rupees int GetP(); // returns paise private: int rupees; (0 <= rupees) int paise; // (0 <= paise < 100) }; Now write the denition and implementation of the class Dollars which has two private integer members (dollarPart and centsPart). Neither dollar nor cents can be negative and cents should be less than 100. For this class, write the following: (1 point) a constructor that takes two integers d and c as parameters and sets dollarPart = d and centsPart = c. (1 point) a constructor that takes in a Rupees object and a positive non-zero double conversionRate. dollars = rupees * conversionRate (4 points) member operator + that adds a dollar object to the current object and returns the new object. (4 points) Overload the << operator so that if d.dollarPart = 45 and d.centsPart = 75, cout << "You have " << d << "."; will display You have $45.75 . (Note that this operator is not a member of the class). You should not call the accessor functions in class Rupees from the class Dollars. You are allowed to add one line to the denition of class Rupees (Hint: Trust in your friends). 5 Additional Sheet 6
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Johns Hopkins - CTE - 628
GLOBE Tech Lesson Plan Format with Assistive Technology Tools &amp; StrategiesObjectives: Challenge Question: Materials: Accommodation Notes: Collaboration Notes: Tools and StrategiesColor coding removable tabs Graphic organizer software Graphic o
University of Florida - CGS - 3460
Pointer (III)CGS 3460, Lecture 30 Mar 27, 2006 Hen-I YangPreviously.Address and Indirection Operators. Use of Pointers.Quiz 4On May 31, Friday, at the beginning of the class 20 Minutes, 3 Questions CoversHomework 4 Textbook: Chapter 7 10, Sl
Johns Hopkins - CTE - 324
Translate beliefs into a shared vision.Mission Statement: collaboratively?What do you hope to accomplish by teachingTask Determine who will be responsible for the following teaching tasks. Planning core content Providing accommodation/modific
Johns Hopkins - CTE - 1523
JohnsHopkinsUniversity SchoolofEducation GraduateCertificateinSchoolAdministrationforSpecialEducation Leaders 851.603 SchoolLaw Syllabus CreditHours: 3ClassTime: WeeklyandonlinethroughtheElectronicLearningCommunity (ELC).Onefacetofacemeetingsession
University of Florida - COT - 7094
Quiz-81)(20 pts) How many different one-to-one functions are there from a set with 3 elements to a set with 8 elements.Set A Set B- - - - - - - - - -For set A, you can select 8.7.6 different positions. So the answer is P(8,3) 2) 20 pts) Use t
University of Florida - COT - 3100
1. q T T F F p T F T F pq T F F F q(p q) T T F FSame truth values they are equivalent 2. q T T F F p T F T F q F F T T p F T F T p q T T F T q (p q) F F F T (q (p q) p T T T TSo it is a tautology 3. Let p=T, q=F, r=T. ( p q ) ( q r) ( T F )
Princeton - MATH - 104
Partial Fractions Irreducible quadratics in the denominator Suppose that in working a problem by partial fractions you encounter a fraction with irreducible quadratic denominator. How do you integrate it? For example, let I = x2 x+3 dx. + 4x + 7 x+3
Princeton - CHE - 246
PRINCETON UNIVERSITY: Department of Chemical Engineering THERMODYNAMICS (CHE 246) Pablo G. Debenedetti and Athanassios Z. Panagiotopoulos THERMODYNAMIC PROPERTIES OF MIXTURES1. Mixing Properties 2. Partial Molar Quantities 3. Gibbs-Duhem Equation 4.
Sewanee - PHYSICS - 104
Problem 17.13 Magnetic fields in the home (a) At any instant the wires make magnetic fields in opposite directions. Since I2 is closer, this results in a small net field. Assuming the wires are very long, the maximum magnitude of the timevarying magn
Maryland - ENEE - 624
University of Maryland at College Park Department of Electrical and Computer EngineeringENEE 624 Advanced Digital Signal Processing Problem Set 6 SolutionsSpring 2003 Monday, April 21, 2003Problem 6.1(a) We can readily show this by induction. L
Maryland - ENEE - 664
Toledo - PHYS - 3320
Lecture 5: Atomic spectra and lasers28 January 2009Atomic Spectra and Lasers(Krane 8.7 - 8.8)Bosons and fermionsFermi-Dirac statistics: electrons: AtomsTwo particles in the same state is forbidden. Review: Line spectra Stimulated emissio
Toledo - PHYS - 3320
Lecture 4: Optical spectra and Xrays23 January 2009Atomic Spectra(Krane 8.5 - 8.7)Review: Adding angular momentumr r r r S = s1 + s2 + s3 + L r r r J = L+ Sr r r r L = l1 + l2 + l3 + LS, P, D, 1P, 2P, 3P, 4 P, Review: LS coupling Hunds
Johns Hopkins - CTE - 541
Advantages and Disadvantages Matrix Scoring ToolTo receive 10 points each week: Identify at least one differentiated instructional strategy or practice on the matrix Provide a bulleted list or paragraph of advantages of the strategy for your gr
University of Florida - U - 971119
CNS /Update Newsletter FeatureNERDC Expenses (Actual Basis) and Debt ServiceCNS Document ID: u971119aLast Updated: 4/19/00UF Computing &amp; Networking Services112 Bryant Space Sciences Bldg, University of Florida P.O. Box 112050 Gainesville Flori
University of Florida - U - 981112
CNS /Update Newsletter FeatureANNUAL REVIEW 1997-1998 NERDC Expenses (Accrual Basis) and Debt ServiceCNS Document ID: U981112ALast Updated: 11/09/98UF Computing &amp; Networking Services112 Bryant Space Sciences Bldg, University of Florida P.O. Bo
University of Florida - U - 990203
CNS /Update Newsletter FeatureUF URLs and Subnet Information to be StandardizedCNS Document ID: u990203aLast Updated: 9/9/99UF Computing &amp; Networking Services112 Bryant Space Sciences Bldg, University of Florida P.O. Box 112050 Gainesville Flo
Neumont - CSC - 1953
Supreme Court of Canada Binet v. The Queen, [1954] S.C.R. 52 Date: 1953-12-18 Clermont Binet Appellant; and Her Majesty The Queen Respondent.1953: September 21; 1953: December 18. Present: Rinfret C.J., and Taschereau, Rand, Cartwright and Fauteux J
Toledo - PHYS - 3320
Physics 3320 M 16 February 2009ReviewReview of the main facts and ideas needed for Exam #1. The exam will be based on Krane Chapters 8,9. But a knowledge of Chapters 1-7, as well as introductory physics is also assumed. 1 2 3 Homework: Understand
Toledo - PHYS - 6140
Lecture 2: Particles and Waves28 August 2008Waves and ParticlesRef. Krane chapters 3,48/28/08PhotonsE = hf Photon energy: Photon momentum: p = h / Maxwell (radiation pressure): E = pcEnergy-momentum relation for a particle of mass m: B
Princeton - COS - 597
COS 597A: Principles of Database and Information SystemsRepresentation Choices Convert to relational representation use indexes on relational attributes see textIndexing for XML Use native representation directly represent tree model node
University of Florida - AST - 1002
Admin.1. 2. Class website http:/www.astro.ufl.edu/~jt/teaching/ast1002/index.html Discussion sectionsTuesday (period 4, 10.40-11.30am), Bryant 3 Wednesday (period 8, 3pm-3.50pm), Bryant 7 Thursday (period 5, 11.45am-12.35pm), Bryant 3 office hr: Th
University of Florida - AST - 1002
Key Concepts: Lectures 14Terrestrial Planets: Overview - How do the properties of planets depend on their mass? MercuryThe Planets The Terrestrial PlanetsMarsMercury - Overview Closest Planet to the Sun Only a little bigger than the MoonPr
University of Florida - AST - 1002
Key Concepts: Lecture 32: GalaxiesGalaxy Types: Spirals, Ellipticals, IrregularsThe Classification of Galaxies Galaxies can be classified by how they appear on the skySpiral Density Waves How flattened the spheroid is How prominent the disk an
Princeton - CS - 226
COS 226 Lecture 8: Balanced trees Symbol Table, Dictionary records with keys INSERT SEARCH Goal: Symbol table implementation with O(lgN) GUARANTEED performance for both search and insert (and other ST operations) Three approaches 1. PROBABILISTIC &quot;gu
Princeton - CS - 226
COS 226 Lecture 21: Network Flow Classical problem-solving model (1940s) OPERATIONS RESEARCH Modern implementations benefit from Graph algorithm technology PQ and data structure design Researchers still seek efficient algorithms many variations many
Neumont - CSC - 1953
Supreme Court of Canada Binet v. The Queen, [1954] S.C.R. 52 Date: 1953-12-18 Clermont Binet Appellant; and Her Majesty The Queen Respondent.1953: September 21; 1953: December 18. Present: Rinfret C.J., and Taschereau, Rand, Cartwright and Fauteux J
UNLV - MATH - 122
Math 122Chapter 8 Review Solutions1.2.3. Answers vary 4. Additive Identity 5. 2x = 20, x = 10 6. From the venn diagram in number 2, any whole number is an integer, but there are integers (the negatives) that are not whole numbers. An example
University of Florida - CWR - 4542
CWR 4542 Water Resources EngineeringLecture Packet 5: Estimating Peak RunoffCourse website:http:/www.ce.ufl.edu/~markn/CWR4542Estimating RunoffTopics covered in this lecture packet Direct runoff Initial losses Runoff coefficients Travel time
University of Florida - SPN - 3300
NOTA IMPORTANTE: Remember that if you do not have directly in your keyboard the accents and keys, you can obtain them with the combination of keys: -&gt; Alt-160 &gt; Alt 0193 -&gt; Alt-130 &gt;Alt 0201 -&gt; Alt-161 &gt;Alt 0205 -&gt; Alt-162 &gt; Alt 0211 -&gt; Alt
University of Florida - EML - 4500
EXAMPLE Directly assembling global matrix equation (applying BC in the element level) Element property &amp; direction cosine tableElem AE/L i -&gt; j 1 206105 1 -&gt; 3 2 206105 1 -&gt; 2 3 206105 1 -&gt; 42 2 F 45q 3 1 1 3I-30 90 210l = cosI 0.866 0 0.86
University of Florida - EML - 5215
Computational Model of Astronaut Exercising on the International Space StationSensitivity Study of Knee Joint Torque as a Function of Spring Contact ForcesJeff ReinboltThis report is submitted in fulfillment of the requirements for the EGM 5430
Toledo - PHYS - 8870
Toledo - PHYS - 7810
D RAFT VERSION S EPTEMBER 6, 2008A Preprint typeset using LTEX style emulateapj v. 03/07/07MODELING THE STRUCTURE OF HOT STAR DISKSJ. E. B JORKMANRitter Observatory, MS 113, Department of Physics and Astronomy, University of Toledo, Toledo, OH 4
Toledo - PHYS - 7810
Toledo - PHYS - 7810
Toledo - PHYS - 7810
Physics 6/7810 - Fall 2008Class Project: Assignment #11. Select one of the following classes of objects for your project: i) T Tauri stars ii) Herbig Ae/Be stars iii) Be stars iv) B[e] stars v) LBV stars vi) Wolf-Rayet (WR) stars vii) Asymptotic Gi
Toledo - PHYS - 7810
Toledo - PHYS - 7810
Modeling the Structure of Hot Star DisksJ. E. Bjorkman Ritter Observatory, MS 113, Department of Physics and Astronomy, University of Toledo, Toledo, OH 43606-3390, USA and A. C. Carcio Instituto de Astronomia, Geof sica e Cincias Atmosfricas, Unive
Toledo - PHYS - 8870
Toledo - ASTR - 1010
The Origin of the Solar SystemChapter 6Observational Constraints Motion all planets orbit Sun same direction; same plane most rotate in same direction Chemical Jupiter &amp; Saturn same composition as Sun Other planets systematic decrease
University of Florida - PHY - 4604
6Operator Formalism IMomentum operator6.1In eqs. 5/(47-48) found dx|(x)|2 = dp|f (p)|2(1)suggesting that if |(x)|2 is the probability density for nding the particle in spatial range [x, x + dx], then |f (p)|2 is prob. density for nding par
University of Florida - PHY - 4604
PHY4604Introduction to Quantum Mechanics Fall 2004 Test 3 SOLUTIONS Dec. 3, 2004No calculators or other materials. If you don't recall a formula, ask and I might be able to help. If you can't do one part of a problem, solve subsequent parts in term
University of Florida - PHY - 4604
PHY4604Introduction to Quantum Mechanics Fall 2004 Problem Set 9 Nov. 9, 2004 Due: Nov. 17, 2004 Reading: Griths Chapter 4 1. Ladder Operators. A simultaneous eigenfunction of the anuglar momentum operators L2 and Lz can be labelled as m . In the st
University of Florida - PHZ - 7427
PHZ7427Solid State II Spring 2003 Final April 16, 2003 Due: April 26, 2003. Do problems number 1 and 2, as well as 3 of 5 subsequent problems 1. Short answer (please write enough to convince me you understand what is going on). (a) Explain how neutro
University of Florida - PHY - 6346
Chapter 5 Fourier Expansions and Separation of Variables in Rectangular CoordinatesEigenfunctions come naturally in the treatment of vibrations in a conned space. Electromagnetic eigenmodes arise in the same way as their mechanical counterpart, such
University of Florida - PHY - 6346
Physics 6346, Electromagnetic Theory I Fall 2000 Homework 4 (Revised 9/20/00) Due Friday, September 22, 5:00 p.m. Reading: Chapter 2. 1. Fourier series. Consider the function f (x) = x( x), 0 x . (1)(a) Periodically extend this function as an ev
University of Florida - CGS - 3464
CGS 3464Spring 2005 Final Exam ReviewChapters Covered Focus on Chapters 9 19 Assume you know chapters 1 8 Emphasis on concepts What? When? How? Why?Exam Format (Draft) Total 70 points 10 x 2 point questions Shortanswers Multiple
University of Florida - COP - 5536
Bloom Filters Differential Files Simple large database. File of records residing on disk. Single key. Index to records.Nave Mode Of OperationKey Problems. Index and File change with time. Sooner or later, system will crash.Index Recov
University of Florida - COP - 3530
Backtracking And Branch And BoundSubset &amp; Permutation Problems Subset problem of size n. Nonsystematic search of the space for the answer takesO(p2n) time, where p is the time needed to evaluate each member of the solution space. Permutation
University of Florida - CAP - 4621
;(defun quad_roots1 (a b c) ; (setq temp (sqrt (- (* b b) (* 4 a c) ;(list (/ (+ (- b) temp) (* 2 a);(/ (- (- b) temp) (* 2 a); 1 2 1; temp is globally defined (defun quad_roots2 (a b c) (let (temp) (setq temp (sqrt (- (* b b) (* 4 a c)
University of Florida - AEB - 6182
Utility Functions, Risk Aversion Coefficients and TransformationsLecture VIRisk Aversion Coefficients for Specific Utility Functions Quadratic Utility Function: To specify the appropriate shape of the utility function, the quadratic function bec
Toledo - ASTR - 4810
ASTR 4810/PHYS 5810 Fall 2001 Homework #3 - Due Weds, 26 Sept 2001 1) The star z Tau has coordinates = 05h 37m 38.6s, = +21 08 33 (2000.0). It has a parallax p = 0.0079 and a proper motion m = +0s.007/century, m = - 2.20/century. Its radial velo
Princeton - CS - 522
Toledo - ASTR - 1010
ANNOUNCEMENTS Observing Extra Credit (last chance) (weather permitting)TONIGHT, Thurs 29 Apr, 8:45-9:45pm turn in pass at final exam or drop off at my officeHomework for today was WORKBOOK EXERCISE: &quot;Expansion of the Universe&quot; (pg. 87-88 i
Toledo - CMHS - 5010
Literature Review 1 Running head: HOW TO WRITE LITERATURE REVIEW PAPERSHow To Write Literature Review Papers in Counselor Education Martin H. Ritchie University of ToledoLiterature Review 2 Abstract General requirements for preparing a literature
Johns Hopkins - LTWNET - 0004
Plataforma-LTW.com / Net Label- Release: LTWNET0004 Artist: Rec_Overflow Album: Doomed EP Date: 2004- 01_Doom.mp3 02_Overdose.mp3 03_Euphony.mp3 (Featuring Rafael Cantero) 04_Chastisement.mp3-- Original Format: Mp3 (192k) Audio Tr
Johns Hopkins - LTWNET - 0013
Plataforma-LTW.com / Net Label- Release: LTWNET0013 Artist: Crisopa Album: Bisagra EP Date: 2005-01 vulos.mp302 Nuestro viejo 747.mp303 O-P-Q-A.mp304 Regalos.mp3 - Original Format: Mp3 (192k) Audio Tracks: 4 Video Extras: 0-
Princeton - COS - 426
Course SyllabusI. Image processing II. Rendering3D RenderingAdam Finkelstein Princeton University COS 426, Spring 2005III. Modeling IV. AnimationImage Processing(Rusty Coleman, CS426, Fall99)Rendering(Michael Bostock, CS426, Fall99)Model
University of Florida - COE - 143
FAC Committee March 25, 2009 Members Present: M. Brownell, J. Kranzler, L. Lamme, M. League, J. Repetto, C. West-Olatunji Task: Continue our discussion to define promotion criteria for Clinical Assistant Professors. Current understanding (based on in
University of Florida - WEB - 143
FAC Committee March 25, 2009 Members Present: M. Brownell, J. Kranzler, L. Lamme, M. League, J. Repetto, C. West-Olatunji Task: Continue our discussion to define promotion criteria for Clinical Assistant Professors. Current understanding (based on in