0% found this document useful (0 votes)
11 views

Lab5 Database Design

Uploaded by

MUHAMMAD AIMAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Lab5 Database Design

Uploaded by

MUHAMMAD AIMAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

SESSION : SESI 1 2021/2022

DEPARTMENT : JTMK
ASSESSMENT : LABORATORY TASK 5

CODE COURSE: DFC 20113

COURSE NAME: PROGRAMMING FUNDAMENTALS

PROGRAMME: DDT SEMESTER : 1/2/3/4/5/6

DATE : TIME : 2 HOUR

INSTRUCTION TO CANDIDATES:

1. Do NOT open until you are allowed to do so.


2. This paper contains:
1 questions- Answer All

NAME : MUHAMMAD AIMAN BIN ZAMRI

REG. NO : 19DDT20F2017

PROGRAMME : DDT-DIPLOMA TEKNOLOGI MAKLUMAT

LECTURER : EN. AZRIN AZLI BIN SUHAIMI

This paper contains 5 printed pages (including the front page)

Prepared by: Verified by:

(Lecturer) (Head of Department/Head of Programme


/ Course Coordinator)

Date: Date:
LABORATORY TASK 5

Instruction: Answer all the questions below.

1. Write and study below segment code.


2. Add two(2) other function for defisit calorie calculation ( refer to the given formulas
below for defisit formula)
3. Instructions: Print out your C++ codes and Output and save it in document with
PDF format.

References:

Formula to calculate BMR:


a) Man : (10 X Weight)+(6.25 X Height)-(5 X Age)+5
b) Woman : (10 X Weight)+(6.25 X Height)-(5 X Age)-161
c) Defisit formula:
a. defisit_takAktif = ((bmr* 14)-7700)/14
b. defisit_Aktif = ((kel* 14)-7700)/14

(CLO 2P)
[ 20 marks]

// PROGRAM MENGIRA BMR DAN DEFISIT KALORI


#include <iostream>
#include <string>
using namespace std;

string jantina;
int kiraBmrL(float,float,float,char);
int kiraBmrP(float,float,float,char);

int main()
{
float age, height, weight;
char gender,aktiviti;
string nama;

// pengguna masukkan maklumat peribadi


cout<<" "<<endl;
cout<<"PROGRAM MENGIRA BMR ANDA"<<endl;
cout<<" "<<endl;
cout<<"\nSila masukkan nama anda : ";
getline(cin,nama);
cout<<"\nPilih jantina anda"<<endl;
cout<<"Lelaki = L / Perempuan P : ";
cin>>gender;
cout<<"\nSila masukkan umur anda :";
cin>>age;
cout<<"\nSila masukkan tinggi anda :";
cin>>height;
cout<<"\nSila masukkan berat anda :";
cin>>weight;

// pengguna pilih tahap keaktifan dalam seminggu


system("CLS");
cout<<"\n "<<endl;
cout<<"Pilih kekerapan aktiviti harian anda dalam tempah
seminggu"<<endl;
cout<<" "<<endl;
cout<<"\n(a) 0 hari seminggu."<<endl;
cout<<"\n(b) 1-3 hari seminggu."<<endl;
cout<<"\n(c) 3-5 hari seminggu."<<endl;
cout<<"\n(d) 6-7 hari seminggu."<<endl;
cout<<"\n(e) Lebih 7 kali seminggu."<<endl;
cout<<"\n "<<endl;
cout<<"Pilih a - e untuk pilihan anda : ";
cin>>aktiviti;

// cetak maklumat pengguna


system("CLS");
cout<<"\n\n "<<endl;

cout<<"\t\tKEPUTUSAN BMR ANDA ADALAH SEPERTI BERIKUT"<<endl;


cout<<" "<<endl;

cout<<"NAMA : "<<nama;
cout<<"\nUMUR : "<<age;
cout<<"\nTINGGI : "<<height;
cout<<"\nBERAT : "<<weight;

// pilihan jantina dan memanggil fungsi mengikut jenis jantina

if (gender=='L' || gender=='l')
{
jantina = "Lelaki";
kiraBmrL(age,height,weight,aktiviti);
}
else if(gender=='P' || gender=='p')
{
jantina = "Perempuan";
kiraBmrP(age,height,weight,aktiviti);
}
else
{
cout<<"\n\nMAAF!!! JANTINA ANDA TIDAK SAH\n";
cout<<"BMR ANDA TIDAK AKAN DIKIRA\n";
}

return 0;
}

// fungsi untuk mengira BMR lelaki


int kiraBmrL(float A,float H, float W,char aktiviti)
{

float bmr,kel;
float def_1, def_2; // utk defisit
bmr = (10*W)+(6.25*H)-(5*A)+5;

if(aktiviti=='a')
kel = bmr*1.2;
else if(aktiviti=='b')
kel = bmr*1.375;
else if(aktiviti=='c')
kel = bmr*1.55;
else if(aktiviti=='d')
kel = bmr*1.725;
else
kel = bmr*1.9;

cout<<"\nJANTINA : "<<jantina;
cout<<"\n\nKeperluan kalori anda untuk sehari tanpa aktiviti
ialah :"<<bmr<<endl;
cout<<"Keperluan kalori sehari mengikut kadar keaktifan anda
ialah :"<<kel<<endl;
cout<<"Defisit kalori sehari tanpa aktiviti ialah :"<< <<endl;
cout<<"Defisit kalori sehari mengikut kadar keaktifan ialah
:"<< ;
cout<<"\n===================================================";
cout<<"\n\n\n\n";

return 0;
}

// fungsi untuk mengira BMR perempuan


int kiraBmrP(float A,float H, float W,char aktiviti)
{

float bmr,kel;
float def_1, def_2; // utk defisit

bmr = (10*W)+(6.25*H)-(5*A)-161;
if(aktiviti=='a')
kel = bmr*1.2;
else if(aktiviti=='b')
kel = bmr*1.375;
else if(aktiviti=='c')
kel = bmr*1.55;
else if(aktiviti=='d')
kel = bmr*1.725;
else
kel = bmr*1.9;

cout<<"\nJANTINA : "<<jantina;
cout<<"\n\nKeperluan kalori anda untuk sehari tanpa aktiviti
ialah :"<<bmr<<endl;
cout<<"Keperluan kalori sehari mengikut kadar keaktifan anda
ialah :"<<kel;
cout<<"Defisit kalori sehari tanpa aktiviti ialah :"<< <<endl;
cout<<"Defisit kalori sehari mengikut kadar keaktifan ialah
:"<< ;
cout<<"\n====================================================";
cout<<"\n\n\n\n";

return 0;
}
ANSWER

CODING
OUTPUT

OUTPUT AFTER ALL DATA INSERTED


Rubric Scheme

Unacceptable Marginal Good Excellent


Topic Marks
(Mark = 0-1) (Mark = 2-3) (Mark =4) (Mark = 5)

 Disorganized  Organized work.  Organized work.  Creatively organized


 Poor use of variables  Good use of variables  Good use of variables work.
Coding Standard names (ambiguous names (unambiguous (unambiguous naming)  Excellent use of variables
naming). naming). names (unambiguous
naming).
 The code is poorly  The code is readable  The code is fairly easy to  The code is exceptionally
Readability organized and very only by someone who read. well organized and very
difficult to read. knows what it is easy to follow.
supposed to be doing.
 Does not execute due to  Executes with some  Executes without errors.  Executes without errors
errors. errors.  User prompts are  Excellent user prompts,
Runtime  User prompts are  User prompts contain understandable, good use of symbols,
misleading or non- little information, poor minimum use of symbols spacing in output.
existent. design. or spacing in output.  Through and organized
 No testing has been  Some testing has been  Thorough testing has testing has been
completed. completed. been completed completed
C++ program basic  No C++ basic program  Three C++ basic program  Five C++ basic program  All the C++ basic
structure correctly structure correctly structure correctly program structure
structure
labelled and function labelled and function labelled and function correctly labelled and
usage usage usage function usage
TOTAL

You might also like