0% found this document useful (0 votes)
180 views6 pages

CCS0007 - Laboratory Exercise 4

This document provides instructions for a laboratory exercise on structures in C++. Students will create and manage records of 5 players using structures. The program will display a menu to add and view player records, compute averages, and show the highest and lowest averages. Structures allow storing different data types together in a record. Members are accessed using the dot operator. The exercise assesses students on requirements specification, data types, input validation, syntax and logic errors, timeliness, and use of comments.

Uploaded by

brandonsydzamora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
180 views6 pages

CCS0007 - Laboratory Exercise 4

This document provides instructions for a laboratory exercise on structures in C++. Students will create and manage records of 5 players using structures. The program will display a menu to add and view player records, compute averages, and show the highest and lowest averages. Structures allow storing different data types together in a record. Members are accessed using the dot operator. The exercise assesses students on requirements specification, data types, input validation, syntax and logic errors, timeliness, and use of comments.

Uploaded by

brandonsydzamora
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

COLLEGE OF COMPUTER STUDIES

CCS007L
(COMPUTER PROGRAMMING 2)

EXERCISE

4
STRUCTURES

Student Name / Group


Name:
Name Role
Members (if Group):

Section:

Professor:
I. PROGRAM OUTCOME/S (PO) ADDRESSED BY THE LABORATORY EXERCISE
• Apply knowledge through the use of current techniques and tools necessary for the IT
profession. [PO: I]

II. COURSE LEARNING OUTCOME/S (CLO)ADDRESSED BY THE LABORATORY EXERCISE


• Adapt and apply appropriate techniques, resources, and modern computing tools to
create computing applications [CLO: 3]

III. INTENDED LEARNING OUTCOME/S (ILO) OF THE LABORATORY EXERCISE


At the end of this exercise, students must be able to:
• Create user- defined types using structures, access its elements and process
• Create a record management program.

IV. BACKGROUND INFORMATION


A structure is a group of elements which are of different type. Each of the elements is
identified by its own identifier and they are called member.
The format for defining a structure is:

struct MyStructure {
Members
};

A structure can be thought of as an object without any member functions. The important
property of structures is that the data in a structure can be a collection of data items of diverse
types.
A structure variable can hold values just like any other variable can. A structure value is a
collection of smaller values called member values.

CCS007L-Computer Programming 2 Page 2 of 6


Here is an example program:
struct database {
int id_number;
int age;
float salary;
};

int main()
{
database employee;
employee.age = 22;
employee.id_number = 1;
employee.salary = 12000.21;
}

Structures are used to represent a record, suppose you want to keep track of your books in
a library. You might want to track the following attributes about each book:
• Title
• Author
• Subject
• Book ID
To access any member of a structure, we use the member access operator (the dot
operator). The member access operator is coded as a period between the structure variable
name and the structure member that we wish to access. You would use struct keyword to
define variables of structure type.

CCS007L-Computer Programming 2 Page 3 of 6


V. GRADING SYSTEM/ RUBRIC

Trait (Excellent) (Good) (Fair) (Poor)


Able to identify Able to identify Able to identify only Unable to
correctly all input correctly all input one input or output identify any input
and output and and output (22-14pts) and output
Requirement
provide alternative. (25-17pts) (20-11pts)
Specification(30pts)
(28-20pts)

Able to apply Able to apply Able to identify Unable to


required data type required data type required data type or identify required
or data structure or data structure data structure but data type
Data type(20pts)
and produce and produce does apply correctly (9-11pts)
correct results (18- partially correct (12-14pts)
20pts) results (15-17pts)
The program works The program works The program The program
and meets all and meets all produces correct produce s
specifications. Does specifications. results but does not incorrect results
Input
exception al Does some display correctly Does (9-11pts)
Validation(20pts)
checking for errors checking for errors not check for errors
and out-of- range and out of range and out of range data
data (18-20pts) data (15-17pts) (12-14pts)
Unable to run Able to run Able to run program Able to run
program (10pts) program but have correctly without any program
Free from syntax, logic error (8-9pts) logic error and correctly without
logic, and runtime display inappropriate any logic error
errors (10pts) output (6-7pts) and display
appropriate
output (5pts)
The program was The program was The program was The program was
delivered on time delivered after 5 delivered after 10 delivered after
(10pts) minutes from the minutes from the 15 (or more)
Delivery (10pts)
time required. (8- time required. (6- minutes from the
9pts) 7pts) time required.
(5pts)
Use of Comments Specific purpose is Specific purpose is Purpose is noted for No comments
(10pts) noted for each noted for each each function. (6- included. (5pts)
function, control function and 7pts)
structure, input control structure.
requirements, and (8-9pts)
output results.
(10pts)

VI. LABORATORY ACTIVITY

CCS007L-Computer Programming 2 Page 4 of 6


INSTRUCTIONS:
Copy your source codes to be pasted in this document as well as a screen shot of your running
output.

ACTIVITY 4.1: Player’s Record

Write a C++ program to keep records and compute for the scores of 5 players. The
information of each player contains: Nickname, Age and two best played scores.

The program will prompt the user to choose the operation of records from a menu as
shown below:

==============================================
MENU
==============================================
1. Add record
2. View players records
3. Compute for the average
4. Show the player(s) who gets the max average.
5. Show the player(s) who gets the min average.
6. Exit

VII. QUESTION AND ANSWER

Briefly answer the questions below. Avoid erasures. For group activity, specify the name of
GROUP MEMBER/s who answered the question. Do not forget to include the source for all
NON-ORIGINAL IDEAS.

• What are the ways to use or declare structure in your program?

• How do you access a member in a structure?

CCS007L-Computer Programming 2 Page 5 of 6


VIII. REFERENCES
• Zak, Dianne (2016). An Introduction to Programming with C++
• Deitel, Paul & Deitel, Harvey (2012). C++ How To Program, Eighth Edition
• https://www.cprogramming.com/tutorial/lesson7.html

CCS007L-Computer Programming 2 Page 6 of 6

You might also like