Class Example. student.h file: Declaration of the student template. #ifndef STUDENT_H_INCLUDED #define STUDENT_H_INCLUDED
|
|
- Doreen Gibbs
- 5 years ago
- Views:
Transcription
1 Class Example student.h file: Declaration of the student template. #ifndef STUDENT_H_INCLUDED #define STUDENT_H_INCLUDED #include <string> #include <fstream> using namespace std; class student public: student(); student(string first, string last, long stuid); ~student(); void setfirstname(string first); void setlastname(string last); void setid(long stuid); string getfirstname(); string getlastname(); long getid(); double getaverage(); int getnumberofgrades(); char getlettergrade(); void addexamscore(double score); void calculateaverage(int numexams); void calculateaverageoftakenexams(); void assignlettergarde(); void printstudentinformation(); void printstudentinformationtofile(ofstream &outfile); private: string firstname; string lastname; long studentid; double examscores[10]; int numgrades; double averageoftakenexams; // average of exams taken. double average; // average of all exams. char lettergrade; ; #endif // STUDENT_H_INCLUDED 1
2 student.cpp file: Implementation of the student template. #include <iostream> #include "student.h" using namespace std; // Constructors student::student() firstname = ""; lastname = ""; studentid = 0; numgrades = 0; student::student(string first, string last, long stuid) firstname = first; lastname = last; studentid = stuid; numgrades = 0; // Destructor student::~student() // Accessor Functions void student::setfirstname(string first) firstname = first; void student::setlastname(string last) lastname = last; void student::setid(long stuid) studentid = stuid; string student::getfirstname() return firstname; string student::getlastname() return lastname; 2
3 long student::getid() return studentid; double student::getaverage() return average; int student::getnumberofgrades() return numgrades; char student::getlettergrade() return lettergrade; void student::addexamscore(double score) if (numgrades < 10) examscores[numgrades] = score; numgrades++; void student::calculateaverage(int numexams) double totalscore = 0; for (int j = 0; j < numgrades; j++) totalscore += examscores[j]; if (numexams > 0) average = totalscore/numexams; else average = 0; void student::calculateaverageoftakenexams() double totalscore = 0; for (int j = 0; j < numgrades; j++) totalscore += examscores[j]; if (numgrades > 0) averageoftakenexams = totalscore/numgrades; else averageoftakenexams = 0; 3
4 void student::assignlettergarde() if (average >= 90) lettergrade = 'A'; else if (average >= 80) lettergrade = 'B'; else if (average >= 70) lettergrade = 'C'; else if (average >= 60) lettergrade = 'D'; else lettergrade = 'F'; void student::printstudentinformation() cout << lastname << ", " << firstname << endl; cout << "Number of Exams Taken: " << numgrades << endl; cout << "Exam Scores: "; for (int j = 0; j < numgrades; j++) cout << examscores[j] << " "; cout << endl; cout << "Average of Exams Taken: " << averageoftakenexams << endl; cout << "Average: " << average << endl; cout << "Letter Grade: " << lettergrade << endl << endl; void student::printstudentinformationtofile(ofstream &outfile) outfile << lastname << ", " << firstname << endl; outfile << "Number of Exams Taken: " << numgrades << endl; outfile << "Exam Scores: "; for (int j = 0; j < numgrades; j++) outfile << examscores[j] << " "; outfile << endl; outfile << "Average of Exams Taken: " << averageoftakenexams << endl; outfile << "Average: " << average << endl; outfile << "Letter Grade: " << lettergrade << endl << endl; 4
5 main.cpp file: #include <iostream> #include <fstream> #include <string> #include "student.h" using namespace std; int SearchID(student mathclass[], int size, long targetid) if (mathclass[i].getid() == targetid) return i; return -1; void SortClassByLastName(student mathclass[], int size) bool swap; student temp; int bottom = size - 1; do swap = false; for (int count = 0; count < bottom; count++) if (mathclass[count].getlastname().compare(mathclass[count+1].getlastname()) > 0) temp = mathclass[count]; mathclass[count] = mathclass[count+1]; mathclass[count+1] = temp; swap = true; bottom--; while(swap!= false); void LoadIntoClass(student mathclass[], int &size, student stu, double examscore) int pos = SearchID(mathclass, size, stu.getid()); if (pos >= 0) mathclass[pos].addexamscore(examscore); else stu.addexamscore(examscore); mathclass[size] = stu; size++; 5
6 void CalculateStudentAveragesAndLetterGrades(student mathclass[], int size) int maxexams = 0; mathclass[i].calculateaverageoftakenexams(); if (mathclass[i].getnumberofgrades() > maxexams) maxexams = mathclass[i].getnumberofgrades(); mathclass[i].calculateaverage(maxexams); mathclass[i].assignlettergarde(); double CalculateClassAverage(student mathclass[], int size) double totalscore = 0; totalscore += mathclass[i].getaverage(); if (size > 0) return totalscore/size; else return 0; void PrintClassReport(student mathclass[], int size) cout << "Student Grade Reports" << endl << endl; mathclass[i].printstudentinformation(); cout << "Class Report" << endl << endl; cout << "Number of students in the class: " << size << endl; double classavg = CalculateClassAverage(mathclass, size); cout << "Class Average: " << classavg << endl << endl; cout << "Grade Distribution" << endl << endl; for (char ch = 'A'; ch <= 'F'; ch++) if (ch!= 'E') cout << ch << ": "; if (mathclass[i].getlettergrade() == ch) cout << "*"; cout << endl; 6
7 void PrintClassReportToFile(student mathclass[], int size, string filename) ofstream outfile; outfile.open(filename.c_str()); outfile << "Student Grade Reports" << endl << endl; mathclass[i].printstudentinformationtofile(outfile); outfile << "Class Report" << endl << endl; outfile << "Number of students in the class: " << size << endl; double classavg = CalculateClassAverage(mathclass, size); outfile << "Class Average: " << classavg << endl << endl; outfile << "Grade Distribution" << endl << endl; for (char ch = 'A'; ch <= 'F'; ch++) if (ch!= 'E') outfile << ch << ": "; if (mathclass[i].getlettergrade() == ch) outfile << "*"; outfile << endl; outfile.close(); int main() student mathclass[20]; int mathclasssize = 0; char ch; ifstream datafile; datafile.open("datafile.txt"); if(!datafile) cout << "Error opening file.\n"; cin.ignore(); return 1; 7
8 while ((ch = datafile.peek())!= EOF) double examscore; string first; string last; long ID; datafile >> first; datafile >> last; datafile >> ID; datafile >> examscore; student stu(first, last, ID); LoadIntoClass(mathclass, mathclasssize, stu, examscore); datafile.close(); CalculateStudentAveragesAndLetterGrades(mathclass, mathclasssize); SortClassByLastName(mathclass, mathclasssize); PrintClassReport(mathclass, mathclasssize); cout << endl; char choice; do cout << "Would you like to save the class information to a file? (Y/N): "; cin >> choice; cin.ignore(255, '\n'); while (toupper(choice)!= 'Y' && toupper(choice)!= 'N'); if (toupper(choice) == 'Y') string filename; cout << "Input Filename: "; getline(cin, filename); PrintClassReportToFile(mathclass, mathclasssize, filename); return 0; 8
9 Output: Student Grade Reports Anderson, Kevin Number of Exams Taken: 4 Exam Scores: Average of Exams Taken: 63 Average: 50.4 Letter Grade: F Black, Joe Number of Exams Taken: 5 Exam Scores: Average of Exams Taken: 80.8 Average: 80.8 Letter Grade: B Doe, John Number of Exams Taken: 3 Exam Scores: Average of Exams Taken: 40 Average: 24 Letter Grade: F Duncan, Jane Number of Exams Taken: 5 Exam Scores: Average of Exams Taken: 85 Average: 85 Letter Grade: B Smith, Rita Number of Exams Taken: 5 Exam Scores: Average of Exams Taken: 64.6 Average: 64.6 Letter Grade: D Thomas, Jackie Number of Exams Taken: 5 Exam Scores: Average of Exams Taken: 80.2 Average: 80.2 Letter Grade: B Zimmermann, Adam Number of Exams Taken: 5 Exam Scores: Average of Exams Taken: 84 Average: 84 Letter Grade: B 9
10 Class Report Number of students in the class: 7 Class Average: 67 Grade Distribution A: B: **** C: D: * F: ** Would you like to save the class information to a file? (Y/N): y Input Filename: testout.txt 10
Files Total: // Files Example 1. #include <iostream> #include <fstream>
Files // Files Example 1 datafile.open("datafile01.txt"); 61.7 86.36 78.12 Total: 261.43 // Prime the reading of the file. while(datafile) cout
More informationCSCI 1370 APRIL 26, 2017
CSCI 1370 APRIL 26, 2017 ADMINISTRATIVIA Quarter Exam #3: scores ranged from 0.70 points to 10.05 points, with a median score of 7.07. Note: a total bonus of 1.00 points (+.5 curve, +.5 group reward) was
More informationSystem Design and Programming II
System Design and Programming II CSCI 194 Section 01 CRN: 20220 Spring 2016 David L. Sylvester, Sr., Assistant Professor Chapter 15 Inheritance, Polymorphism, And Virtual Functions What is Inheritance?
More informationInput and Output File (Files and Stream )
Input and Output File (Files and Stream ) BITE 1513 Computer Game Programming Week 14 Scope Describe the fundamentals of input & output files. Use data files for input & output purposes. Files Normally,
More informationCSCE 110 PROGRAMMING FUNDAMENTALS
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 15. Dictionaries (1): A Key Table Class Prof. amr Goneid, AUC 1 Dictionaries(1): A Key Table Class Prof. Amr Goneid, AUC 2 A Key Table
More informationTutorial letter 202/1/2015
COS1512/202/1/2015 Tutorial letter 202/1/2015 Introduction to Programming II COS1512 Semester 1 School of Computing This tutorial letter contains the solution to Assignment 2 IMPORTANT INFORMATION: Please
More informationTutorial letter 202/2/2018
COS1512/202/2/2018 Tutorial letter 202/2/2018 Introduction to Programming II COS1512 Semester 2 School of Computing This tutorial letter contains the solution to Assignment 2 IMPORTANT INFORMATION: Please
More informationBITG 1113: Files and Stream LECTURE 10
BITG 1113: Files and Stream LECTURE 10 1 LEARNING OUTCOMES At the end of this lecture, you should be able to: 1. Describe the fundamentals of input & output files. 2. Use data files for input & output
More informationReading from and Writing to Files. Files (3.12) Steps to Using Files. Section 3.12 & 13.1 & Data stored in variables is temporary
Reading from and Writing to Files Section 3.12 & 13.1 & 13.5 11/3/08 CS150 Introduction to Computer Science 1 1 Files (3.12) Data stored in variables is temporary We will learn how to write programs that
More informationConvenient way to deal large quantities of data. Store data permanently (until file is deleted).
FILE HANDLING Why to use Files: Convenient way to deal large quantities of data. Store data permanently (until file is deleted). Avoid typing data into program multiple times. Share data between programs.
More informationCSC 138 Structured Programming CHAPTER 4: TEXT FILE [PART 1]
CSC 138 Structured Programming CHAPTER 4: TEXT FILE [PART 1] LEARNING OBJECTIVES Upon completion, you should be able to: o define C++ text files o explain the benefits of using I/O file processing o explain
More informationCSc Introduc/on to Compu/ng. Lecture 19 Edgardo Molina Fall 2011 City College of New York
CSc 10200 Introduc/on to Compu/ng Lecture 19 Edgardo Molina Fall 2011 City College of New York 18 Standard Device Files Logical file object: Stream that connects a file of logically related data to a program
More informationCSI33 Data Structures
Outline Department of Mathematics and Computer Science Bronx Community College November 9, 2016 Outline Outline 1 Chapter 9: C++ Classes Outline Chapter 9: C++ Classes 1 Chapter 9: C++ Classes Class Syntax
More informationWeek 3: File I/O and Formatting 3.7 Formatting Output
Week 3: File I/O and Formatting 3.7 Formatting Output Formatting: the way a value is printed: Gaddis: 3.7, 3.8, 5.11 CS 1428 Fall 2014 Jill Seaman spacing decimal points, fractional values, number of digits
More informationCPE Summer 2015 Exam I (150 pts) June 18, 2015
Name Closed notes and book. If you have any questions ask them. Write clearly and make sure the case of a letter is clear (where applicable) since C++ is case sensitive. You can assume that there is one
More informationCS 103 Unit 10 Slides
1 CS 103 Unit 10 Slides C++ Classes Mark Redekopp 2 Object-Oriented Programming Model the application/software as a set of objects that interact with each other Objects fuse data (i.e. variables) and functions
More informationEECS 183 Week 8 Diana Gage. www-personal.umich.edu/ ~drgage
EECS 183 Week 8 Diana Gage www-personal.umich.edu/ ~drgage Classes! My favorite topic J Definition of a class How many different definitions can we come up with? What is a class? A class is a container
More informationLAB 7.1 Working with One-Dimensional Arrays
LAB 7.1 Working with One-Dimensional Arrays Copy and paste the following program into Visual Studio IDE. This program will read in a group of test scores (positive integers from 1 to 100) from the keyboard
More informationCPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)
Name Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Relational Expression Iteration Counter Count-controlled loop Loop Flow
More informationThis test is OPEN Textbook and CLOSED notes. The use of computing and/or communicating devices is NOT permitted.
University of Toronto Faculty of Applied Science and Engineering ECE 244F PROGRAMMING FUNDAMENTALS Fall 2013 Midterm Test Examiners: T.S. Abdelrahman, V. Betz, M. Stumm and H. Timorabadi Duration: 110
More informationName Section: M/W T/TH Number Definition Matching (8 Points)
Name Section: M/W T/TH Number Definition Matching (8 Points) 1. (8 pts) Match the words with their definitions. Choose the best definition for each word. Iteration Counter Event Counter Loop Abstract Step
More information2. It is possible for a structure variable to be a member of another structure variable.
FORM 1(put name, form, and section number on scantron!!!) CS 162 Exam I True (A) / False (B) (2 pts) 1. What value will the function eof return if there are more characters to be read in the input stream?
More informationfor (int i = 1; i <= 3; i++) { do { cout << "Enter a positive integer: "; cin >> n;
// Workshop 1 #include using namespace std; int main () int n, k; int sumdigits; for (int i = 1; i n; cin.clear (); cin.ignore (100,
More informationCSCE Practice Midterm. Data Types
CSCE 2004 - Practice Midterm This midterm exam was given in class several years ago. Work each of the following questions on your own. Once you are done, check your answers. For any questions whose answers
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 2 Monday, March 20, 2017 Total - 100 Points B Instructions: Total of 13 pages, including this cover and the last page. Before starting the exam,
More informationNotes on the 2016 Exam
Notes on the 2016 Exam The stuff inside borders is all that you needed to write. The rest is commentary. Please also read notes on previous years exams especially the 2005 set of notes. Note that up to
More informationCSC1322 Object-Oriented Programming Concepts
CSC1322 Object-Oriented Programming Concepts Instructor: Yukong Zhang February 18, 2016 Fundamental Concepts: The following is a summary of the fundamental concepts of object-oriented programming in C++.
More informationChapter void Test( int, int, int ); // Function prototype int main() // Function heading { int h; // Local variable
EXERCISE ANSWERS Chapter 7 Exam Preparation Exercises 1 Function call The mechanism that transfers control to the body of a function Argument list A mechanism by which functions communicate with each other;
More informationText File I/O. #include <iostream> #include <fstream> using namespace std; int main() {
Text File I/O We can use essentially the same techniques we ve been using to input from the keyboard and output to the screen and just apply them to files instead. If you want to prepare input data ahead,
More informationName Section: M/W T/TH Number Definition Matching (6 Points)
Name Section: M/W T/TH Number Definition Matching (6 Points) 1. (6 pts) Match the words with their definitions. Choose the best definition for each word. Event Counter Iteration Counter Loop Flow of Control
More informationIntroducing C++ to Java Programmers
Introducing C++ to Java Programmers by Kip Irvine updated 2/27/2003 1 Philosophy of C++ Bjarne Stroustrup invented C++ in the early 1980's at Bell Laboratories First called "C with classes" Design Goals:
More informationLinked List using a Sentinel
Linked List using a Sentinel Linked List.h / Linked List.h Using a sentinel for search Created by Enoch Hwang on 2/1/10. Copyright 2010 La Sierra University. All rights reserved. / #include
More informationLecture 3 The character, string data Types Files
Lecture 3 The character, string data Types Files The smallest integral data type Used for single characters: letters, digits, and special symbols Each character is enclosed in single quotes 'A', 'a', '0',
More informationCS 103 Unit 10 Slides
1 CS 103 Unit 10 Slides C++ Classes Mark Redekopp 2 Object-Oriented Programming Model the application/software as a set of objects that interact with each other Objects fuse data (i.e. variables) and functions
More informationthis Pointer, Constant Functions, Static Data Members, and Static Member Functions this Pointer (11.1) Example of this pointer
this Pointer, Constant Functions, Static Data Members, and Static Member Functions 3/2/07 CS250 Introduction to Computer Science II 1 this Pointer (11.1) functions - only one copy of each function exists
More informationCMSC 202 Midterm Exam 1 Fall 2015
1. (15 points) There are six logic or syntax errors in the following program; find five of them. Circle each of the five errors you find and write the line number and correction in the space provided below.
More information1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl?
Exercises with solutions. 1. a) What #include statement do you put at the top of a program that does uses cin, cout or endl? #include b) What using statement do you always put at the top of
More informationReview Problems for Final Exam. 1. What is the output of the following program? #include <iostream> #include <string> using namespace std;
Review Problems for Final Exam 1. What is the output of the following program? int draw(int n); int n = 4; while (n>0) n = draw(n); int draw(int n) for(int i = 0; i < n; i++) cout
More informationPage 1 of 5. *** person.cpp *** #include "person.h" #include <string> #include <iostream> using namespace std; *** person.h ***
#ifndef PERSON_H #define PERSON_H #include "date.h" *** person.h *** class Person // constructors Person( ); Person( const string &name, const int id ); Person( const string &name, const int id, const
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 02: Using Objects MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Using Objects 2 Introduction to Object Oriented Programming Paradigm Objects and References Memory Management
More informationC++ STREAMS; INHERITANCE AS
C++ STREAMS; INHERITANCE AS PUBLIC, PROTECTED, AND PRIVATE; AGGREGATION/COMPOSITION Pages 731 to 742 Anna Rakitianskaia, University of Pretoria C++ STREAM CLASSES A stream is an abstraction that represents
More informationPROGRAMMING EXAMPLE: Checking Account Balance
Programming Example: Checking Account Balance 1 PROGRAMMING EXAMPLE: Checking Account Balance A local bank in your town is looking for someone to write a program that calculates a customer s checking account
More informationlecture04: Constructors and Destructors
lecture04: Largely based on slides by Cinda Heeren CS 225 UIUC 13th June, 2013 Announcements lab debug due Saturday night (6/15) mp1 due Monday night (6/17) Warmup: what happens? /** @file main.cpp */
More informationThe American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011
The American University in Cairo Department of Computer Science & Engineering CSCI 106-07&09 Dr. KHALIL Exam-I Fall 2011 Last Name :... ID:... First Name:... Form I Section No.: EXAMINATION INSTRUCTIONS
More informationC++ Input/Output Chapter 4 Topics
Chapter 4 Topics Chapter 4 Program Input and the Software Design Process Input Statements to Read Values into a Program using >>, and functions get, ignore, getline Prompting for Interactive Input/Output
More informationSummary of basic C++-commands
Summary of basic C++-commands K. Vollmayr-Lee, O. Ippisch April 13, 2010 1 Compiling To compile a C++-program, you can use either g++ or c++. g++ -o executable_filename.out sourcefilename.cc c++ -o executable_filename.out
More informationObjects and streams and files CS427: Elements of Software Engineering
Objects and streams and files CS427: Elements of Software Engineering Lecture 6.2 (C++) 10am, 13 Feb 2012 CS427 Objects and streams and files 1/18 Today s topics 1 Recall...... Dynamic Memory Allocation...
More informationSystem Design and Programming II
System Design and Programming II CSCI 194 Section 01 CRN: 10968 Fall 2017 David L. Sylvester, Sr., Assistant Professor Chapter 12 Advanced File Operation File Operations A file is a collection of data
More informationJordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A
Jordan University of Science & Technology Department of Computer Science CS 211 Exam #1 (23/10/2010) -- Form A Name: ID#: Section #: Day & Time: Instructor: Answer all questions as indicated. Closed book/closed
More informationStructures. e.g., Smith Mary F brown 27 lawyer
Structures! Problem: A television quiz show has information about a number of people who want to become contestants. The name of each potential contestant and some personal characteristics are on file.
More informationChapte t r r 9
Chapter 9 Session Objectives Stream Class Stream Class Hierarchy String I/O Character I/O Object I/O File Pointers and their manipulations Error handling in Files Command Line arguments OOPS WITH C++ Sahaj
More informationStrings and Streams. Professor Hugh C. Lauer CS-2303, System Programming Concepts
Strings and Streams Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter
More informationCSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.
Name: Print legibly! Section: COMPUTER SCIENCE 261 PROGRAMMING CONCEPTS EXAM 1 VERSION 1 Fall 2014 150 Points Absolutely no electronic devices may be used during this exam. 1. No cell phones, computers,
More informationAgenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures
The main body and cout Agenda 1 Fundamental data types Declarations and definitions Control structures References, pass-by-value vs pass-by-references The main body and cout 2 C++ IS AN OO EXTENSION OF
More informationC++ Mini Lessons Last Update: Feb 7, 2018
C++ Mini Lessons Last Update: Feb 7, 2018 From http://www.onlineprogramminglessons.com These C++ mini lessons will teach you all the C++ Programming statements you need to know, so you can write 90% of
More informationReview: C++ Basic Concepts. Dr. Yingwu Zhu
Review: C++ Basic Concepts Dr. Yingwu Zhu Outline C++ class declaration Constructor Overloading functions Overloading operators Destructor Redundant declaration A Real-World Example Question #1: How to
More informationChapter 10 RECORDS (Structs )
Chapter 10 RECORDS (Structs ) In Chapter 6 we learned that an array is set up to use multiple elements of the same data type. What if we want to have several different related types within one data structure
More informationCS 115 Exam 3, Spring 2010
Your name: Rules You must briefly explain your answers to receive partial credit. When a snippet of code is given to you, you can assume o that the code is enclosed within some function, even if no function
More informationAdvanced File Operations. Review of Files. Declaration Opening Using Closing. CS SJAllan Chapter 12 2
Chapter 12 Advanced File Operations Review of Files Declaration Opening Using Closing CS 1410 - SJAllan Chapter 12 2 1 Testing for Open Errors To see if the file is opened correctly, test as follows: in.open("cust.dat");
More informationObject Oriented Programming COP3330 / CGS5409
Object Oriented Programming COP3330 / CGS5409 Multiple Inheritance Template Classes and Functions Inheritance is supported by most object oriented languages C++ allows a special kind of inheritance known
More informationCSCE Practice Midterm. Data Types
CSCE 2004 - Practice Midterm This midterm exam was given in class several years ago. Work each of the following questions on your own. Once you are done, check your answers. For any questions whose answers
More informationMultiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More information1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.
1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol. B. Outputs to the console a floating point number f1 in scientific format
More informationFirst Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010
First Exam Computer Programming 326 Dr. St. John Lehman College City University of New York Thursday, 7 October 2010 NAME (Printed) NAME (Signed) E-mail Exam Rules Show all your work. Your grade will be
More informationMultiple Choice Questions (20 questions * 6 points per question = 120 points)
EECS 183 Fall 2014 Exam 2 Closed Book Minimal Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including cell phones, calculators,
More informationECE 462 Exam 1. 6:30-7:30PM, September 22, 2010
ECE 462 Exam 1 6:30-7:30PM, September 22, 2010 I will not receive nor provide aid to any other student for this exam. Signature: You must sign here. Otherwise, the exam is not graded. This exam is printed
More informationFile I/O Christian Schumacher, Info1 D-MAVT 2013
File I/O Christian Schumacher, chschuma@inf.ethz.ch Info1 D-MAVT 2013 Input and Output in C++ Stream objects Formatted output Writing and reading files References General Remarks I/O operations are essential
More informationMultiple Choice Questions (20 questions * 5 points per question = 100 points)
EECS 183 Winter 2014 Exam 1 Closed Book Closed Notes Closed Electronic Devices Closed Neighbor Turn off Your Cell Phones We will confiscate all electronic devices that we see including cell phones, calculators,
More informationFile handling Basics. Lecture 7
File handling Basics Lecture 7 What is a File? A file is a collection of information, usually stored on a computer s disk. Information can be saved to files and then later reused. 2 File Names All files
More informationStreams in C++ Stream concept. Reference information. Stream type declarations
Stream concept A stream represent a sequence of bytes arriving, being retrieved, being stored, or being sent, in order. A stream is continuos and offer sequential access to the data. Each byte can be read
More informationC++ does not, as a part of the language, define how data are sent out and read into the program
Input and Output C++ does not, as a part of the language, define how data are sent out and read into the program I/O implementation is hardware dependent The input and output (I/O) are handled by the standard
More informationReview Questions for Final Exam
CS 102 / ECE 206 Spring 11 Review Questions for Final Exam The following review questions are similar to the kinds of questions you will be expected to answer on the Final Exam, which will cover LCR, chs.
More informationDeveloped By : Ms. K. M. Sanghavi
Developed By : Ms. K. M. Sanghavi Designing Our Own Manipulators We can design our own manipulators for certain special purpose.the general form for creating a manipulator without any arguments is: ostream
More informationDefinition Matching (10 Points)
Name SOLUTION Closed notes and book. If you have any questions ask them. Write clearly and make sure the case of a letter is clear (where applicable) since C++ is case sensitive. There are no syntax errors
More informationGE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004
GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004 Functions and Program Structure Today we will be learning about functions. You should already have an idea of their uses. Cout
More informationCOL 100. Minor 2 Exam - Practice
COL 100. Minor 2 Exam - Practice Name: Entry Number: Group: Notes: Total number of questions: 4. Max Marks: 20 All answers should be written on the question paper itself. The last two sheets in the question
More information[CSE10200] Programming Basis ( 프로그래밍기초 ) Chapter 7. Seungkyu Lee. Assistant Professor, Dept. of Computer Engineering Kyung Hee University
[CSE10200] Programming Basis ( 프로그래밍기초 ) Chapter 7 Seungkyu Lee Assistant Professor, Dept. of Computer Engineering Kyung Hee University Input entities Keyboard, files Output entities Monitor, files Standard
More informationMultiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)
Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program
More informationCOMP322 - Introduction to C++
COMP322 - Introduction to C++ Winter 2011 Lecture 05 - I/O using the standard library & Introduction to Classes Milena Scaccia School of Computer Science McGill University February 1, 2011 Final note on
More informationpointers & references
pointers & references 1-22-2013 Inline Functions References & Pointers Arrays & Vectors HW#1 posted due: today Quiz Thursday, 1/24 // point.h #ifndef POINT_H_ #define POINT_H_ #include using
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 1 Monday, February 13, 2017 Total - 100 Points A Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,
More informationCSCE 206: Structured Programming in C++
CSCE 206: Structured Programming in C++ 2017 Spring Exam 1 Monday, February 13, 2017 Total - 100 Points B Instructions: Total of 11 pages, including this cover and the last page. Before starting the exam,
More informationSample Code: OUTPUT Daily Highs & Lows
Name1: Name2: Class Day / Time: Due Date: Sample Code: OUTPUT Daily Highs & Lows This program will obtain from the user 3 sets of data including a date, the high temperature and a low temperature for that
More informationFile I/O. File Names and Types. I/O Streams. Stream Extraction and Insertion. A file name should reflect its contents
File I/O 1 File Names and Types A file name should reflect its contents Payroll.dat Students.txt Grades.txt A file s extension indicates the kind of data the file holds.dat,.txt general program input or
More informationAssignment 2 Solution
Assignment 2 Solution Date.h #ifndef DATE_H #define DATE_H #include class Date time_t date; public: Date(); Date(const Date&) = default; Date(time_t); // Date in time_t format Date(const char*);
More informationThis sheet must be the cover page for every programming assignment. Total
This sheet must be the cover page for every programming assignment. Name Joe Student Assignment Title May the Greatest Integer Win (do not write below this line; for grader use only) Validity (up to 70%)
More informationPIC 10A. Lecture 17: Classes III, overloading
PIC 10A Lecture 17: Classes III, overloading Function overloading Having multiple constructors with same name is example of something called function overloading. You are allowed to have functions with
More informationMultiple Inheritance and Object Layout in C++
Multiple Inheritance and Object Layout in C++ Tutorial 08 Leonid Barenboim 8/6/2009 Outline 1 The Academia 2 Makefile Outline 1 The Academia 2 Makefile The Academia Person Has an name and an id. Academician
More informationCSCE 110 PROGRAMMING FUNDAMENTALS
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++ Prof. Amr Goneid AUC Part 16. Linked Lists Prof. amr Goneid, AUC 1 Linked Lists Prof. amr Goneid, AUC 2 Linked Lists The Linked List Structure Some Linked List
More informationA SHORT COURSE ON C++
Introduction to A SHORT COURSE ON School of Mathematics Semester 1 2008 Introduction to OUTLINE 1 INTRODUCTION TO 2 FLOW CONTROL AND FUNCTIONS If Else Looping Functions Cmath Library Prototyping Introduction
More informationSimple File I/O.
Simple File I/O from Chapter 6 http://www.cplusplus.com/reference/fstream/ifstream/ l / /f /if / http://www.cplusplus.com/reference/fstream/ofstream/ I/O Streams I/O refers to a program s input and output
More informationCS 141, Introduction to Computer Science Fall Midterm Exam
CS 141, Introduction to Computer Science Fall 2006 Midterm Exam Name: Student ID: 1 (12 points) Data Types Where possible give 3 examples of possible values for each of the following data types. Use proper
More informationChapter 3 - Notes Input/Output
Chapter 3 - Notes Input/Output I. I/O Streams and Standard I/O Devices A. I/O Background 1. Stream of Bytes: A sequence of bytes from the source to the destination. 2. 2 Types of Streams: i. Input Stream:
More informationWeek 5: Files and Streams
CS319: Scientific Computing (with C++) Week 5: and Streams 9am, Tuesday, 12 February 2019 1 Labs and stuff 2 ifstream and ofstream close a file open a file Reading from the file 3 Portable Bitmap Format
More informationI/O Streams and Standard I/O Devices (cont d.)
Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore how to read data from the standard input device Learn how to use predefined
More informationการทดลองท 8_2 Editor Buffer Array Implementation
การทดลองท 8_2 Editor Buffer Array Implementation * File: buffer.h * -------------- * This file defines the interface for the EditorBuffer class. #ifndef _buffer_h #define _buffer_h * Class: EditorBuffer
More informationPIC 10A. Final Review: Part I
PIC 10A Final Review: Part I Final exam The final exam is worth 30% of your grade, same weight as 2 midterms. Could be 50% if grading option 2 turns out better for you. Length is also roughly 2 midterms
More informationC++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 11: Records (structs)
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 11: Records (structs) Objectives In this chapter, you will: Learn about records (structs) Examine various operations on a
More informationFundamentals of Programming Session 28
Fundamentals of Programming Session 28 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2014 These slides have been created using Deitel s slides Sharif University of Technology Outlines
More informationMore File Operations. Lecture 17 COP 3014 Spring april 18, 2018
More File Operations Lecture 17 COP 3014 Spring 2018 april 18, 2018 eof() member function A useful member function of the input stream classes is eof() Stands for end of file Returns a bool value, answering
More information