Lab4 Task2- Solution LAB ASSIGNMENT:
|
|
- Chloe Hancock
- 5 years ago
- Views:
Transcription
1 Lab4 Task2- Solution LAB ASSIGNMENT: Write down a StudentAccount class having the following attributes and operations (methods) and save it as studacct.h file: Attributes: long studentid String studentname Double balance Operations: StudentAccount() : will prompt the user to enter all the relevant data from the keyboard StudentAccount() : Initialize the studentid, studentname and his account balance (will receive these data as parameters from the main() GetID() : will return the student ID to the main function GetName() : will return the student name to the main function GetBalance() : will return the current balance of the student to the main function Withdraw() : will take the amount as argument transferred from the main function and use the value to decrease the account (WILL WORK WHEN YOU WITHDRAW MONEY) If the balance of student is less than the withdraw amount do not let the student to withdraw money. Display an appropriate message. Deposit() : will take the amount as argument transferred from the main function and use the value to increase the account (WILL WORK WHEN YOU DEPOSIT MONEY) WriteAccount() : display the studentid, student name and current balance StudentAccount CLASS UML DIAGRAM : StudentAccount StudentID:long StudentName:string Balance:double StudentAccount() StudentAccount(sid:long,n:char *,bal:double) GetID():long GetName():char * GetBalance():double Withdraw (amount:double):void Deposit (amount:double):void WriteAccount():void 1) Write a main program to create 2 StudentAccount objects using pointers: Display all account details of both objects Then prompt for and input deposit amount for first object Update his account Then prompt for and input withdrawal amount for second object Update his account Display the ID and Name of first object Display the ID and current balance of first object Display all account details of second object
2 Display all account details of first object Task1 - Solution1 : //studentaccount.h class StudentAccount long studentid; double balance; char studentname[20]; public: StudentAccount() cout<<"\nenter Student Name : "; cin>>studentname; cout<<"\nenter Student ID No : "; cin>>studentid; cout<<"\nenter Student Account Balance : "; cin>>balance; StudentAccount(long std, double bal, char * n) studentid=std ; balance=bal; strcpy(studentname,n); long GetID() return studentid; char * GetName() return studentname; double GetBalance() return balance; void Withdraw ( double wit ) if(amount>balance) cout<<"insufficient balance!!!"; else balance -= wit ; void Deposit ( double dep ) balance += dep ; void WriteAccount() cout<<"\nstudent Name : "<<studentname; cout<<"\tid No : "<<studentid; cout<<"\taccount Balance : "<<balance; 2
3 3 ; Task1 - Solution 2: (This pointer) //studentaccount.h class studentaccount private: long studentid; string studentname; double balance; public: studentaccount() cout<<"enter student id : "; cin>>this->studentid; cout<<"enter student name : "; cin>>this->studentname; cout<<"enter student balance: "; cin>>this->balance; studentaccount(long studentid, string studentname, double balance) this->studentid = studentid; this->studentname = studentname; this->balance = balance; long getid() return this->studentid; string getname() return this->studentname; double getbalance() return this->balance; void withdraw(double amount) if(amount>balance) cout<<"insufficient balance!!!"; else this->balance -= amount;
4 4 ; void deposit(double amount) this->balance += amount; void writeaccount() cout<<"student Id: "<<this->studentid<<endl; cout<<"student Name:"<<this->studentName<<endl; cout<<"stundet Balance:"<<this->balance<<endl; //main ( ) for both solutions. #include "student.h" double b; studentaccount s1(964554, "Bilge Ercan",4500), *s1ptr; studentaccount s2(996547, "Pinar Sahin",2575), *s2ptr; s1ptr=&s1; s2ptr=&s2; cout<<"\naccount details Student 1:"; s1ptr->writeaccount(); cout<<"\naccount details of Student 2: "; s2ptr->writeaccount(); cout<<"\nenter deposit amount for Student2: "; cin >> b ; s2ptr->deposit ( b ) ; cout<<"\nenter withdrawal amount for Student 1 : "; cin >> b ; s1ptr->withdraw ( b ) ; cout<<"\nstudent ID No : "<<s1ptr->getid(); cout<<"\tname : "<<s1ptr->getname(); cout<<"\nstudent ID No : "<<s2ptr->getid(); cout<<"\tbalance : "<<s1ptr->getbalance(); cout<<"\naccount details of Student 1 : "<<endl; s1ptr->writeaccount(); cout<<"\naccount details of Student 2 : "<<endl; s2ptr->writeaccount(); system("pause");
5 5 Task2: Write a separate main program which will do the following: Create an array of 5 studentaccount objects using pointers. Display all the data members of the array object in an appropriate format. Task2 - Solution1: #include studentaccount.h studentaccount st[5]; studentaccount *stptr=st; cout<<"\n\ndata member values of all array of object elements :"; for ( int k=0;k<5;k++) stptr->writeaccount(); stptr++; system("pause"); Task2 - Solution2: #include studentaccount.h studentaccount st[5]; studentaccount *stptr=st; cout<<"\n\ndata member values of all array of object elements :"; for ( int k=0;k<5;k++) stptr[k].writeaccount(); system("pause"); Task2 - Solution 3:
6 6 #include studentaccount.h studentaccount stdarr[3]; studentaccount *obj1; obj1 = stdarr; for(int i=0;i<3;i++) (obj1+i)->writeaccount(); system( pause );
public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance;
public class Account { private int id; private static int nextaccountid = 0; private String name; private double balance; public double deposit(double amount) { public double withdraw(double amount) {
More informationDeveloped By Strawberry
Experiment No. 3 PART A (PART A: TO BE REFFERED BY STUDENTS) A.1 Aim: To study below concepts of classes and objects 1. Array of Objects 2. Objects as a function argument 3. Static Members P1: Define a
More information6.096 Introduction to C++
MIT OpenCourseWare http://ocw.mit.edu 6.096 Introduction to C++ January (IAP) 2009 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms. MASSACHUSETTS INSTITUTE
More informationExercises 1. class member { int membernum = 25; float memberpay; public void Input(cin >> membernum >> memberpay); void Output; }
Exercises 1 Part 1: Explain the output of the following code without running it: struct data { float z; char type; }; int main() { data D1 = {20, 'P'}; cout
More informationObject oriented programming
Exercises 7 Version 1.0, 11 April, 2017 Table of Contents 1. Inheritance.................................................................. 1 1.1. Tennis Player...........................................................
More informationUsing the Xcode Debugger
g Using the Xcode Debugger J Objectives In this appendix you ll: Set breakpoints and run a program in the debugger. Use the Continue program execution command to continue execution. Use the Auto window
More informationC C C C++ 2 ( ) C C++ 4 C C
# 7 11 13 C 4 8 11 20 C 9 11 27 C++ 1 10 12 4 C++ 2 11 12 11 C++ 3 12 12 18 C++ 4 C++ 5 13 1 8 ( ) 14 1 15 C++ 15 1 22 2 (D) ( ) C++ 3 6 Hello C++ 4 5 1. make Makefile.c (arithmetic.c) main main arithmetic
More informationCSE115 Introduction to Computer Science I Coding Exercise #7 Retrospective Fall 2017
This week the main activity was a quiz activity, with a structure similar to our Friday lecture activities. The retrospective for the quiz is in Quiz-07- retrospective.pdf This retrospective explores the
More informationEncapsulation. Mason Vail Boise State University Computer Science
Encapsulation Mason Vail Boise State University Computer Science Pillars of Object-Oriented Programming Encapsulation Inheritance Polymorphism Abstraction (sometimes) Object Identity Data (variables) make
More informationPractice problem on defining and using Class types. Part 4.
CS180 Programming Fundamentals Practice problem on defining and using Class types. Part 4. Implementing object associations: Applications typically consist of collections of objects of different related
More informationLAB 4.1 Relational Operators and the if Statement
LAB 4.1 Relational Operators and the if Statement // This program tests whether or not an initialized value of num2 // is equal to a value of num1 input by the user. int main( ) int num1, // num1 is not
More informationHandout 8 Classes and Objects Continued: Static Variables and Constants.
Handout 8 CS603 Object-Oriented Programming Fall 16 Page 1 of 8 Handout 8 Classes and Objects Continued: Static Variables and Constants. 1. Static variable Declared with keyword static One per class (instead
More informationSTUDENT LESSON A5 Designing and Using Classes
STUDENT LESSON A5 Designing and Using Classes 1 STUDENT LESSON A5 Designing and Using Classes INTRODUCTION: This lesson discusses how to design your own classes. This can be the most challenging part of
More informationCSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism
CSCI-1200 Computer Science II Fall 2006 Lecture 23 C++ Inheritance and Polymorphism Review from Lecture 22 Added parent pointers to the TreeNode to implement increment and decrement operations on tree
More informationCHAPTER 4 Structures
CHAPTER 4 Structures Page 1 Structures: Arrays are one of the most widely used data structures in programming languages. The limitation of arrays, however, is that all the elements must be of the same
More information//employee.h class employee { private: string name; double salary; string gender; int empid; static int empcounter; public: employee() {
//employee.h class employee private: string name; double salary; string gender; int empid; static int empcounter; public: employee() cout
More informationHere, type declares the base type of the array, which is the type of each element in the array size defines how many elements the array will hold
Arrays 1. Introduction An array is a consecutive group of memory locations that all have the same name and the same type. A specific element in an array is accessed by an index. The lowest address corresponds
More informationCSCI-1200 Data Structures Fall 2017 Lecture 25 C++ Inheritance and Polymorphism
SI-1200 ata Structures Fall 2017 Lecture 25 ++ Inheritance and Polymorphism Review from Lecture 24 (& Lab 12!) Finish hash table implementation: Iterators, find, insert, and erase asic data structures
More informationBasics of Java Programming. Hendrik Speleers
Hendrik Speleers Overview Building blocks of a Java program Classes Objects Primitives Methods Memory management Making a (simple) Java program Baby example Bank account system A Java program Consists
More informationKapil Sehgal PGT Computer. Science Ankleshwar Gujarat
Classes Chapter 4 Classes and Objects Data Hiding and Encapsulation Function in a Class Using Objects Static Class members Classes Class represents a group of Similar objects A class is a way to bind the
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 informationClass CSE F. *slides are from CSE S at SKKU & at MIT
Class CSE2013-17F *slides are from CSE2013-16S at SKKU & 6.096 at MIT Representing a Vector In the context of geometry, a vector consists of 2 points: a start and a finish Each point itself has an x and
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 informationClass Example. student.h file: Declaration of the student template. #ifndef STUDENT_H_INCLUDED #define STUDENT_H_INCLUDED
Class Example student.h file: Declaration of the student template. #ifndef STUDENT_H_INCLUDED #define STUDENT_H_INCLUDED #include #include using namespace std; class student public:
More informationProgramming a Bank Database. We ll store the information in two tables: INTEGER DECIMAL(10, 2)
WE1 W o r k e d E x a m p l e 2 2.1 Programming a Bank Database In this Worked Example, we will develop a complete database program. We will reimplement the ATM simulation of Chapter 12, storing the customer
More informationReview. these are the instance variables. these are parameters to the methods
Review Design a class to simulate a bank account Implement the class Write a demo program that creates bank accounts Write junit tests for the bank account class Review What data items are associated with
More informationCMPS 221 Sample Final
Name: 1 CMPS 221 Sample Final 1. What is the purpose of having the parameter const int a[] as opposed to int a[] in a function declaration and definition? 2. What is the difference between cin.getline(str,
More informationITEC 243 Lab 5- Task 3- Solution
ITEC 243 Lab 5- Task 3- Solution Car Regno: string Color:string Count:static int Car() getregno( ):string getcolor( ): string getnumberofcars( ):static int ~Car( ) Define car.h according to the following
More informationData types. CISC 1600/1610 Computer Science I. Class dog. Introducing: classes. Class syntax declaration. Class syntax function definitions 12/2/2015
CISC 1600/1610 Computer Science I Classes Professor Daniel Leeds dleeds@fordham.edu JMH 328A Data types Single pieces of information one integer int one symbol char one truth value bool Multiple pieces
More informationUsing Parallel Arrays. Parallel Array Example
Using Parallel Arrays Parallel arrays: two or more arrays that contain related data A subscript is used to relate arrays: elements at same subscript are related Arrays may be of different types Parallel
More informationClasses and Data Abstraction: struct
Classes and Data Abstraction: struct There are many instances in programming where we need more than one variable in order to represent an object. For example, to represent yourself, you might want to
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 informationECE462Exam3. 08:10-09:20AM, November 20, 2009
ECE462Exam3 08:10-09:20AM, November 20, 2009 IcertifythatIwillnotreceivenorprovideaidtoanyotherstudentforthisexam. Signature: Youmustsignhere.Otherwise,theexamisnotgraded. This exam is printed double sides.
More informationSyntax to define a Structure: struct structurename { datatype membername1; datatype membername2;... } ; For Example:
STRUCTURE IN C++ 1 A Structure is a collection of variables of different data types under one name. A structure defines a new user defined data type for your current program using which items of different
More information$ % $ % BankAccount. public class BankAccount {... private??? balance; } "commands, transformers, mutators! "abstract state! "queries, accessors!
"! public class { private??? balance; "! # "! "commands, transformers, mutators! "abstract state! "queries, accessors! "constructors! & "! public class { private double balance; "! void "this! x.command1();
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 informationCS 106X, Lecture 14 Classes and Pointers
CS 106X, Lecture 14 Classes and Pointers reading: Programming Abstractions in C++, Chapter 6, 11 This document is copyright (C) Stanford Computer Science and Nick Troccoli, licensed under Creative Commons
More informationNote: The buy help from the TA for points will apply on this exam as well, so please read that carefully.
CS 215 Spring 2018 Lab Exam 1 Review Material: - All material for the course up through the Arrays I slides - Nothing from the slides on Functions, Array Arguments, or Implementing Functions Format: -
More information02. Brieflydescribe the following fundamental concepts of object oriented world
OOAD Pass Paper 2012 & Answer Q1 01.What is meant by "Object Orientation"? Object Orientation is meant by concepts as object that have data fields (attributes that describe the object) and associated procedures
More informationClass 09 Slides: Polymorphism Preconditions. Table of Contents. Postconditions
Class 09 Slides: Polymorphism Preconditions Students are familiar with inheritance and arrays. Students have worked with a poorly written program in A08 that could benefit from polymorphism. Students have
More informationData Structures Lab II. Binary Search Tree implementation
Data Structures Lab II Binary Search Tree implementation Objectives: Making students able to understand basic concepts relating to Binary Search Tree (BST). Making students able to implement Binary Search
More informationQuarter 1 Practice Exam
University of Chicago Laboratory Schools Advanced Placement Computer Science Quarter 1 Practice Exam Baker Franke 2005 APCS - 12/10/08 :: 1 of 8 1.) (10 percent) Write a segment of code that will produce
More informationObject oriented programming
Exercises 10 Version 1.0, 4 May, 2017 Table of Contents 1. Static members and exceptions............................................... 1 1.1. Problem................................................................
More informationEE 109 Lab 8a Conversion Experience
EE 109 Lab 8a Conversion Experience 1 Introduction In this lab you will write a small program to convert a string of digits representing a number in some other base (between 2 and 10) to decimal. The user
More informationEduardo M. Breijo Baullosa May 2, Assignment 17. Report
Eduardo M. Breijo Baullosa May 2, 2012 Cesar I. Cruz ICOM4015 Assignment 17 Report The Automated teller machine is a computer that allows the interaction between bank account information and its respective
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 informationArray Part dimensional arrays - 2-dimensional array operations - Arrays of Strings - N-dimensional arrays
Array Array Part 1 - Accessing array - Array and loop arrays must be used with loops - Array and bound checking Be careful of array bound: invalid subscripts => corrupt memory; cause bugs - Array initialization
More information3/12/2018. Structures. Programming in C++ Sequential Branching Repeating. Loops (Repetition)
Structures Programming in C++ Sequential Branching Repeating Loops (Repetition) 2 1 Loops Repetition is referred to the ability of repeating a statement or a set of statements as many times this is necessary.
More informationObject Oriented Pragramming (22316)
Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data
More informationArrays in C++ Instructor: Andy Abreu
Arrays in C++ Instructor: Andy Abreu Reason behind the idea When we are programming, often we have to process a large amount of information. We can do so by creating a lot of variables to keep track of
More informationExercise1. // classes first example. #include <iostream> using namespace std; class Rectangle. int width, height; public: void set_values (int,int);
Exercise1 // classes first example class Rectangle int width, height; void set_values (int,int); int area() return width*height; ; void Rectangle::set_values (int x, int y) width = x; height = y; int main
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 informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II Year / Semester: III / V Date: 08.7.17 Duration: 45 Mins
More informationDeveloped By Strawberry
Experiment No. 4 PART A (PART A: TO BE REFFERED BY STUDENTS) A.1. Aim: To understand the following concept of constructors. 1. To create constructor. 2. To understand concept of no argument constructor.
More informationCS31: Introduction to Computer Science I Winter 2014
Final Practice TA: Zhou Ren 1. Assume the following variable declarations: int foo = 0; int *ptr = &foo; Which of the following statements will change the value of foo to 1? (a) ptr++; (b) foo++; (c) (*foo)++;
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 informationWhere do we stand on inheritance?
In C++: Where do we stand on inheritance? Classes can be derived from other classes Basic Info about inheritance: To declare a derived class: class :public
More informationTHE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering. Computer Programming (ENG236) - Homework 3
THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering Computer Programming (ENG236) - Homework 3 A. By using Visual Studio 2010, implement all member functions of the
More informationC++ Programming: From Problem Analysis to Program Design, Third Edition
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection) Control Structures A computer can proceed: In sequence Selectively (branch) - making
More informationUNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED
UNIT 3 ARRAYS, RECURSION, AND COMPLEXITY CHAPTER 11 CLASSES CONTINUED EXERCISE 11.1 1. static public final int DEFAULT_NUM_SCORES = 3; 2. Java allocates a separate set of memory cells in each instance
More informationOBJECTS. An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently.
OBJECTS An object is an entity around us, perceivable through our senses. Types of Object: Objects that operate independently. Objects that work in associations with each others. Objects that frequently
More informationCSE 143 Lecture 3. More ArrayList; object-oriented programming. reading: 10.1;
CSE 143 Lecture 3 More ArrayList; object-oriented programming reading: 10.1; 8.1-8.7 slides created by Marty Stepp http://www.cs.washington.edu/143/ Out-of-bounds Legal indexes are between 0 and the list's
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 15 Chapter 11
Chapter 15 Chapter 11 /** * Deposit money into the account * @param amount The amount to be deposited * * @pre true * @post IF amount >= 0 * THEN getbalance() = @pre.getbalance() + amount * ELSE getbalance()
More informationDate: AIM. Write a Java program to demo simple inheritance PROCEDURE
Ex.No 7 Date: AIM INHERITANCE Write a Java program to demo simple inheritance PROCEDURE 1. Create a class stud which includes student name,major,year, rollno. 2. Create a class mark which extends the stud
More informationОбјектно ориентирано програмирање
Аудиториски вежби 7 Верзија 1.0, 03 април, 2017 Содржина 1. Наследување............................................................... 1 1.1. Задача.................................................................
More informationObject oriented programming
Exercises 8 Version 1.0, 11 April, 2017 Table of Contents 1. Polymorphism............................................................... 1 1.1. Publications.............................................................
More informationvoid Add() { cin >> trainnumber; gets(trainname); } void display() { cout<<trainnumber <<":"<<TrainName<<end;
. T SHREE MAHAPRABHU PUBLIC SCHOOL & COLLEGE QUESTION BANK FOR BOARD EXAMINATION 016-17 SUBJECT COMPUTER SCIENCE (Code: 083) Q1. Answer the following questions: a) Name the header file(s) that shall be
More informationOverview. OOP: model, map, reuse, extend. Examples of objects. Introduction to Object Oriented Design
Overview Introduction to Object Oriented Design Understand Classes and Objects. Understand some of the key concepts/features in the Object Oriented paradigm. Benefits of Object Oriented Design paradigm.
More informationLab 14 SERACHI G Dr. John P. Abraham
Lab 14 SERACHI G Dr. John P. Abraham We can only do a linear search on an unsorted array, but on a sorted array we can do a binary search. In this chapter we will study two different algorithms for searching,
More informationCOMP-202 Unit 8: Defining Your Own Classes. CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation
COMP-202 Unit 8: Defining Your Own Classes CONTENTS: Class Definitions Attributes Methods and Constructors Access Modifiers and Encapsulation Defining Our Own Classes (1) So far, we have been creating
More informationECE 462 Exam 3. 11:30AM-12:20PM, November 17, 2010
ECE 462 Exam 3 11:30AM-12:20PM, November 17, 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 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 informationCSci 1113 Final. Name: Student ID:
CSci 1113 Final Name: Student ID: Instructions: Please pick and answer any 10 of the 12 problems for a total of 100 points. If you answer more than 10 problems, only the first 10 will be graded. The time
More informationAC55/AT55 OBJECT ORIENTED PROGRAMMING WITH C++ DEC 2013
Q.2 a. Discuss the fundamental features of the object oriented programming. The fundamentals features of the OOPs are the following: (i) Encapsulation: It is a mechanism that associates the code and data
More informationPart I: Short Answer (6 questions, 18 points total)
CSE 143 Sp01 Midterm 2 Sample Solution page 1 of 7 Part I: Short Answer (6 questions, 18 points total) Answer all of the following questions. READ EACH QUESTION CAREFULLY. Answer each question in the space
More informationLab 12 Object Oriented Programming Dr. John Abraham
Lab 12 Object Oriented Programming Dr. John Abraham We humans are very good recognizing and working with objects, such as a pen, a dog, or a human being. We learned to categorize them in such a way that
More informationCSEN401 Computer Programming Lab. Topics: Introduction and Motivation Recap: Objects and Classes
CSEN401 Computer Programming Lab Topics: Introduction and Motivation Recap: Objects and Classes Prof. Dr. Slim Abdennadher 16.2.2014 c S. Abdennadher 1 Course Structure Lectures Presentation of topics
More informationCS 1302 Chapter 9 (Review) Object & Classes
CS 1302 Chapter 9 (Review) Object & Classes Reference Sections 9.2-9.5, 9.7-9.14 9.2 Defining Classes for Objects 1. A class is a blueprint (or template) for creating objects. A class defines the state
More informationPractical Workbook Object Oriented Programming
Practical Workbook Object Oriented Programming Name : Year : Batch : Roll No : Department: Department of Computer & Information Systems Engineering NED University of Engineering & Technology Karachi 75270,
More informationCS 115 Midterm 2 Solutions
CS115Midterm2Solutions April9,2009 Rules Youmustbrieflyexplainyouranswerstoreceivepartialcredit. Whenasnippetofcodeisgiventoyou,youcanassumethatthecodeis enclosedwithinsomefunction,evenifnofunctiondefinitionisshown.you
More informationEAS 230 Fall 2002 Section B
EAS 230 Fall 2002 Section B Exam #2 Name: Person Number: Instructions: ƒ Total points are 100, distributed as shown by [ ]. ƒ Duration of the Exam is 50 minutes. I ) State whether True or False [25] Indicate
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 informationOperating Systems Lab
Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 3 Fork() in C and C++ programming
More informationFundamentals of Programming CS-110. Lecture 2
Fundamentals of Programming CS-110 Lecture 2 Last Lab // Example program #include using namespace std; int main() { cout
More informationAgenda: Notes on Chapter 3. Create a class with constructors and methods.
Bell Work 9/19/16: How would you call the default constructor for a class called BankAccount? Agenda: Notes on Chapter 3. Create a class with constructors and methods. Objectives: To become familiar with
More informationCS 617 Object Oriented Systems Lecture 5 Classes, Classless World:Prototypes, Instance Variables, Class Variables, This/Self 3:30-5:00 pm Thu, Jan 17
Objects, Interfaces and CS 617 Object Oriented Systems Lecture 5, Classless World:Prototypes, Instance Variables, Class Variables, This/Self 3:30-5:00 pm Thu, Jan 17 Rushikesh K Joshi Department of Computer
More informationCS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:
CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : In mathematics,
More informationData types. CISC 1600/1610 Computer Science I. Class dog. Introducing: classes. Class syntax declaration. Class syntax function definitions 4/19/2015
CISC 1600/1610 Computer Science I Classes Professor Daniel Leeds dleeds@fordham.edu JMH 328A Data types Single pieces of information one integer int one symbol char one truth value bool Multiple pieces
More informationCS242 COMPUTER PROGRAMMING
CS242 COMPUTER PROGRAMMING I.Safa a Alawneh Variables Outline 2 Data Type C++ Built-in Data Types o o o o bool Data Type char Data Type int Data Type Floating-Point Data Types Variable Declaration Initializing
More informationIntroduction to Inheritance
Introduction to Inheritance James Brucker These slides cover only the basics of inheritance. What is Inheritance? One class incorporates all the attributes and behavior from another class -- it inherits
More informationPointers. Variable Declaration. Chapter 10
Pointers Chapter 10 Variable Declaration When a variable is defined, three fundamental attributes are associated with it: Name Type Address The variable definition associates the name, the type, and the
More informationName. CPTR246 Spring '17 (100 total points) Exam 2
Name CPTR246 Spring '17 (100 total points) Exam 2 1. Pointer parameters (the old C way) In the following program, make all of the changes to convert the call-by-reference parameters in the function computeoptions
More informationFunctions Overview. Functions (aka procedures, subroutines, or methods) are the unit of code decomposition and abstraction
1 Unit 14 Functions Function Decomposition 2 Functions Overview Functions (aka procedures, subroutines, or methods) are the unit of code decomposition and abstraction Map Service ValidateInputs() RetrieveMap()
More informationQUESTIONS AND ANSWERS. 1) To access a global variable when there is a local variable with same name:
Q1. List the usage of :: operator in C++. [AYUSH BANIK -1741012] QUESTIONS AND ANSWERS 1) To access a global variable when there is a local variable with same name: int x; // Global x int main() int x
More informationA brief intro to pointers for the purposes of passing reference parameters
A brief intro to pointers for the purposes of passing reference parameters With respect to functions, we have only talked about pass by value parameters. Today we will discuss pass by reference parameters.
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 informationOutline CSE 142. Specification vs Implementation - Review. CSE142 Wi03 F-1. Instance Variables
Outline CSE 142 Class Implementation in Java Implementing classes in Java Instance variables properties Value-returning methods for queries Void methods for commands Return statement Assignment statement
More informationUniversity of Swaziland Department OfComputer Science Main Examination December 2016
University of Swaziland Department OfComputer Science Main Examination December 2016 Title of paper : C under Linux Course number : CS344 Time Allowed : Three (3) hours Instructions: Answer ALL Questions
More informationParameter Passing Mechanisms. Reference Parameters
Parameter Passing Mechanisms Reference Parameters Function Call Main Function Server Function Arguments Value Parameters Variable Result Problem Using OCD, design and implement a function that, given a
More information