You are on page 1of 9

POLITEKNIK BALIK PULAU

DEPARTMENT OF INFORMATION TECHNOLOGY & COMMUNICATION

DFC 2073
PROGRAMMING FUNDAMENTALS

NAME : MOHAMAD MIKHAIL IKHWAN BIN


MOHAMAD SHAFIE
NO PEND : 21DNS16F1062
CLASS : DNS1A
DATE : 04 SEPTEMBER 2016
EXERCISE : LAB 3
LECTURER : ENCIK RAZI BIN ALIAS
LAB 3 (GROUP A)

#include <iostream>
using namespace std;

int main()
{
int balance = 500;
int amount;
char code;

cout<<"enter your transaction code, d - deposit, w - withdrawal:


\n";
cin>>code;

cout<<"enter your amount: \n";


cin>>amount;

if(code=='d')
{
balance=balance+amount;
cout<<"balance"<<balance;
}

else if(code=='w')
{
balance=balance-amount;
cout<<"balance"<<balance;
}

else
{
cout<<" code not allowed!\n";
}
}
LAB 3 (GROUP B)

#include <iostream>
using namespace std;

int main()
{
int price;
float gst;

cout<<"Enter a price: ";


cin>>price;
cout<<"Enter amount gst: ";
cin>>gst;

switch(price){
case 90 ... 1000:
cout<<"My price is: "<<price+0.2*gst;
break;

case 80 ... 89:


cout<<"My price is: "<<price+0.15*gst;
break;

case 70 ... 79:


cout<<"My price is: "<<price+0.1*gst;
break;

case 60 ... 69:


cout<<"My price is: "<<price+0.08*gst;
break;

case 0 ... 59:


cout<<"My price is: "<<price+0.01*gst;
break;

default:
cout<<" code not allowed!\n";
}
}
LAB 3 (GROUP C)

#include<iostream>
using namespace std;

int main()
{
char grade;
cout<<"Enter grade:";
cin>>grade;

switch(grade){
case 'A' : case 'a':
cout<<"Your get grade "<<grade<<"Congratulation";
break;

case 'B' : case 'b':


cout<<"Your get grade "<<grade<<"Good";
break;

case 'C' : case 'c':


cout<<"Your get grade "<<grade<<"Need more exercise";
break;

case 'D' : case 'd':


cout<<"Your get grade "<<grade<<"Need improvement";
break;

case 'F' : case 'f':


cout<<"Your get grade "<<grade<<"Try again ";
break;

default:
cout<<"Incorrect letter grade entered.";
cout<<"Enter a new grade.\n";
}
}
LAB 3 (GROUP D)

#include<iostream>
using namespace std;

int main()
{
int score;

cout<<"Score:";
cin>>score;

if (score>=80&&score<=100)
{
cout<<"a";
}

else if (score<80&&score>=50)
{
cout<<"b";
}

else if (score<50&&score>=0)
{
cout<<"f";
}

else
{
cout<<"BAD VALUE";
}
}