FAKULTI TEKNOLOGI KEJURUTERAAN UNIVERSITI TEKNIKAL MALAYSIA MELAKA
COMPUTER PROGRAMMING
BETR 1343
SEMESTER 2
SESSION 2016/2017
LAB 5: STRUCTURE
3!5!2017
ATE
NAME OF GROUP MEMBERS " MATRI# NUMBER
MO$AMA RAS$AN BIN MO$ SAI
NAME OF INSTRUCTORS
EN! MO$ $ANIF BIN C$E $ASAN
B07151074%
EN! RAMLAN BIN LATIP
E#AMINER&S COMMENTS
VERIFICATION STAMP
TOTAL MARKS
Document Number N/A Revision Number 4.0 A. I. A. Ra!man"
Issue Number 29.05.2015 Total Pages
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
LAB REPORT FORMAT FOR BETR 1343 ' COMPUTER PROGRAMMING
PART 1 : PRELAB 1.
T#$e T#$e t!e %ollo&ing co'e( com$ile( an' run it using #our ID).
#include using namespace std;
// declare the data structure struct STUD { // declare 4 structure members int number; string id; string name; float score; }; STUD student!""; // $e can ha%e up until !"" sets of these data int main&' { // assign ( sets of data into structure student")number student") number * !; student")id student")id * +,"!-.4(+; student")name student")name * +,ruce 0a1ne+; student")score student") score * 2")(; student!)number student!) number * -; student!)id student!)id * +,"4(32+; student!)name student!)name * +5arle1 6uinn+; student!)score student!) score * ()3; student-)number student-) number * .; student-)id student-)id * +,"222+; student-)name student-)name * +Solomon 7rund1+; student-)score student-) score * 3)(; student.)number student.) number * 4; student.)id student.)id * +,"3((-(-+; student.)name student.)name * +Selina 81le+; student.)score student.) score * 2.)(; student4)number student4) number * (; student4)id student4)id * +,".2.2+; student4)name student4)name * +9ucius :o+; student4)score student4) score * 3); // displa1 the ( sets of data cout << +=D?@tD@t@t=AB@t@tSCE+ << endl; cout << +*********************** +*********** ************************* **********************+ *********+ << endl; cout << student")number student")n umber << +) @t+ << student")id student")i d << +@t+ <<
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
cout << student.)number student.)n umber << +) @t+ << student.)id student.)i d << +@t+ << student.)name << +@t+ << student.)score << endl; cout << student4)number student4)n umber << +) @t+ << student4)id student4)i d << +@t+ << student4)name << +@t+ << student4)score << endl; cout << endl << endl; return "; }
2. *# using for or $hile loo$( o$timi+e t!e $revious co'e so t!at it uses %e&er lines o% co'es( but ac!ieve t!e same results. ,o'einclu'e iostream using names$ace st' // 'eclare t!e 'ata structure struct stu'ent // 'eclare 4 structure members int number c!ar 3i' c!ar 3name %loat score stu'ent1006 // &e can !ave u$ until 100 sets o% t!ese 'ata int main" int i stu'ent10067stu'enti6 struct stu'ent 'umm# // assign 5 sets o% 'ata into structure stu'ent06.number stu'ent06.number 7 1 stu'ent06.i' 7 8*01245:8 stu'ent06.name 7 8*ruce ;a#ne8 ;a#ne8 stu'ent06.score 7 90.5 stu'ent16.number stu'ent16.number 7 2 stu'ent16.i' 7 8*045:<=98 stu'ent16.name 7 8>arle# ?uinn8 stu'ent16.score 7 =5.< stu'ent26.number stu'ent26.number 7 stu'ent26.i' 7 8*0999:::8 stu'ent26.name 7 8@olomon run'#8 stu'ent26.score 7 <:.5 stu'ent6.number stu'ent6.number 7 4
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
stu'ent46.i' 7 8*0:9:98 stu'ent46.name 7 8Cucius oE8 stu'ent46.score 7 <=.= // 'is$la# t!e 5 sets o% 'ata cout 8IND)FGtIDGtGtNAH)GtGt@,R)8 en'l cout 87777777777777777777 87777777777777777777777777777777777777 777777777777777777777777778 777777778 en'l %ori70 i5 iJJ" coutstu'enti6.number coutstu'enti6.number 8. Gt8 stu'enti6.i' 8Gt8 stu'enti6.name 8Gt8 stu'enti6.score en'l cout en'l en'l s#stem 8$ause8" return 0
.
Ho'i%# #our co'e %urt!er so t!at t!e ne& $rogram &ill out$ut t!ese-
0hich data number do 1ou $ish to seeF . =D? D =AB SCE ****************************************************** . ,"222 Solomon 7rund1 3)( 0hich data number do 1ou $ish to seeF ( =D? D =AB SCE ****************************************************** ( ,".2.2 9ucius :o 3)
,o'einclu'e iostream using names$ace st' // 'eclare t!e 'ata structure struct stu'ent // 'eclare 4 structure members int number c!ar 3i'
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
int main" int i(num stu'ent10067stu'enti6 struct stu'ent 'umm# // assign 5 sets o% 'ata into structure stu'ent06.number stu'ent06.number 7 1 stu'ent06.i' 7 8*01245:8 stu'ent06.name 7 8*ruce ;a#ne8 ;a#ne8 stu'ent06.score 7 90.5 stu'ent16.number stu'ent16.number 7 2 stu'ent16.i' 7 8*045:<=98 stu'ent16.name 7 8>arle# ?uinn8 stu'ent16.score 7 =5.< stu'ent26.number stu'ent26.number 7 stu'ent26.i' 7 8*0999:::8 stu'ent26.name 7 8@olomon run'#8 stu'ent26.score 7 <:.5 stu'ent6.number stu'ent6.number 7 4 stu'ent6.i' 7 8*0<552528 stu'ent6.name 7 8@elina B#le8 stu'ent6.score 7 9.5 stu'ent46.number stu'ent46.number 7 5 stu'ent46.i' 7 8*0:9:98 stu'ent46.name 7 8Cucius oE8 stu'ent46.score 7 <=.= cout8;!ic! 'ata number 'o #ou &is! to seeK 8 cinnum couten'len'l // 'is$la# t!e 5 sets o% 'ata cout 8IND)FGtIDGtGtNAH)GtGt@,R)8 en'l cout 87777777777777777777 87777777777777777777777777777777777777 777777777777777777777777778 777777778 en'l coutstu'entnum6.number coutstu'entnum6.number 8. Gt 8 stu'entnum6.i' 8Gt8 stu'entnum6.name 8Gt8 stu'entnum6.score en'l cout en'l en'l s#stem 8$ause8" return 0
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
4. Ho'i%# #our co'e to create an em$t# structure. Lser &ill t!en '#namicall# Me#in t!e sets o% 'ata an' t!e $rogram &ill 'is$la# &!at !e entere' on t!e console screen. @am$le out$ut-
>intcin)ignore&'; getline&cinG studenti)name';
//Use this code to enter name
t
5o$ man1 sets of data do 1ou $ish to enterF nter D !H ,"-((-(( nter =ame !H d$ard =1gma nter Score !H ()! nter D -H ,"!-!- nter =ame -H s$ald Cobblepot nter Score -H 4") Iou enteredH =D? D =AB SCE ************************************************ ! ,"-((-(( d$ard =1gma ()! ,"!-!- s$ald Cobblepot 4")
5o$ man1 sets of data do 1ou $ish to enterF 4 nter D !H ,"!!"!!nter =ame !H 5ar%e1 Dent nter Score !H 2") nter D -H ,"(!-(!nter =ame -H ,ane Dorrance nter Score -H .")2 nter D .H ,""""-(" nter =ame .H Amadeus ArJham nter Score .H 2)( nter D 4H ,"""!3. nter =ame 4H Kictor :ries nter Score 4H ("). Iou enteredH =D?
D
=AB
SCE
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
,o'einclu'e iostream using names$ace st' // 'eclare t!e 'ata structure struct stu'ent c!ar i'156 c!ar name506 %loat score stu'ent1006 // &e can !ave u$ until 100 sets o% t!ese 'ata int main" int i(num struct stu'ent 'umm#
cout8>o& man# sets o% 'ata 'o #ou &is! to enterK 8 cinnum couten'l %or i71i7numiJJ" i71i7numiJJ" cout8)nter ID 8i8 - 8 cinstu'enti6.i' cout8)nter Name 8i8 - 8 cin.ignore" cin.getlinestu'enti6.name(0" cout8)nter @core 8i8 - 8 cinstu'enti6.score couten'l
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
cout en'l en'l s#stem8PAL@)8" return 0
PART 2 : LAB 1( RE)U E)UIRE IREMENT MENT S*+,-. 1: P. *- 1 Y. Y. CGPA Oou !ave to create a $rogram to calculate #our current ,PA. Oou &ill asM t!e user to Me# in t!eir ,PA %or ever# semester. T!en calculate t!eir ,PA ,PA ormula 7 PA1JPA2J..... PA1JPA2J....... .. JPAn"/ JPAn"/
&!ere is #our total semester.
Note C,-* G8* P.-, A** 9CGPA( is 9CGPA( is t!e cumulative $oint average obtain %or t!e semester t!at !ave been com$lete. G8* P.-, A** 9GPA( is 9GPA( is t!e gra'e $oint average obtaine' in $articular semester. @am$le ut$ut2( ANALYSIS
I, Insert number o% semester(semester an' cg$a
P.+* ,alculate cg$a
O,, Dis$la# cg$a
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
3( PROG PROGRA RAM M ESI ESIGN GN lo& ,!art
Start
Insert number of semester
i=0 i++ i
Insert GPA of semester
Calculate GGPA
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
,o'e // @tu'ent @tu'ent Name- Ho!ama' Ras!'an bin Ho!' @ai' // Cab TitleTitle- Data @tructure using struct
@tu'ent ID- *0<1510<49
Date- 0/05/201<
inclu'e iostream inclu'e iomani$ using names$ace st'
struct cg$a c!ar semester406 'ouble g$a
int main" #-
struct cg$a stu'cg$a1006 'ouble g$a(cg$a70 int i(numsem cout8>o& man# semester #ou !ave been com$lete'K 8 cinnumsem
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
couten'l
cout8Oour ,PA - 8%iEe'set$recision2"cg$a/numsemen'l s#stem8$ause8" s#stem 8cls8"
goto # .
4( TESTING @!o& t!e in$ut #ou !ave inserte' an' also t!e $rogram out$ut console.
T*, 1 I,
S**,* ;* <** +.*,*8: 2 E,* **,*: 1=2015/2016 E,* + >. **,* 1=2015/2016: 3!3 E,* **,*: 2=2015/2016 E,* + >. **,* 2=2015/2016: 3!4
O,,
T*, 2
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
O,,
T*, 3 I,
S**,* ;* <** +.*,*8: 2 E,* **,*: 1=2013/2014 E,* + >. **,* 1=2013/2014: 3!0 E,* **,*: 2=2013/2014 E,* + >. **,* 2=2013/2014: 3!26
O,,
1( RE)U E)UIRE IREMENT MENT
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
3( PROG PROGRA RAM M ESI ESIGN GN lo& ,!art
Start
Declare ariables De!ne struct moie " Day# $oie# Director# %ime %ime
i=0 i++ i<&
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
,o'e inclu'e iostream inclu'e iomani$ using names$ace st'
struct movie int 'a# c!ar 3title c!ar 3'irector c!ar 3time
int main"
#int i
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
HSI)i6.timeen'l
couten'l
cout8Please @elect Da#8en'l cout816 Hon'a# Gn26 Tues'a# Tues'a# Gn6 ;e'nes'a# ;e'nes'a# Gn46 T!urs'a# T!urs'a# Gn56 Gn56 ri'a# Gn8 cini couten'l
i% i:"UUi1"" cout8Invali' In$utV8en'l else cout 8DAO GtHSI)
GtGtDIR),TRGtTime GtGtDI R),TRGtTime 8 en'l
cout 8777777777777777777777777777777777777 87777777777777777 7777777777777777777777777777777777777777 77777777777777777777777778 777778 en'l
coutHSI)i16.'a#8.Gt8HSI)i16.title8GtGt8
HSI)i16.'irector8GtGt8HSI)i16.timeen'l
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
4( TESTING @!o& t!e in$ut #ou !ave inserte' an' also t!e $rogram out$ut console.
T*, 1 I, O,,
T*, 2 I,
i72
i75
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
The world’s largest digital library
Try Scribd FREE for 30 days to access over 125 million titles without ads or interruptions! Start Free Trial Cancel Anytime.
O,,
5( POSS POSSIB IBLE LE IMPRO IMPROVE VEME MENT NTS S Describe !o& #ou coul' im$rove #our $rogram i% #ou !a' more time. ;!at