CFP Activities PDF
CFP Activities PDF
CFP Activities PDF
ACTIVITIES
GROUP NAME: A4
MEMBERS:
Aguinillo, Chrisal Collete F.
Aguinillo, Inah Fatima C.
Alamo, Jerson D.
Alarcon, Katrina
SARI-SARI STORE SCENARIO (BOOL)
#include <iostream>
int main()
if (BibiliNgHotdog)
} else {
return 0;
}
OUTPUT:
SARI-SARI STORE SCENARIO (BOOLEAN & LOGICAL
OPERATORS)
#include<iostream>
int main()
cout << "\t\t SARI-SARI STORE SCENARIO (BOOLEAN & LOGICAL OPERATORS) USING IF-ELSE STATEMENT
\n\n";
int quantity;
float price, totalCost;
cout << "Total cost: " << totalCost << " pesos" << endl;
return 0;
}
OUTPUT:
SIMPLE QUIZ USING WHILE LOOP
#include <iostream>
using namespace std;
int main()
{
cout << "\t\t\t ******************************************************************** \n";
cout << "\t\t\t\t\t Camarines Sur Polytechnic Colleges \n";
cout << "\t\t\t\t\t\t Nabua, Camarines Sur \n";
cout << "\t\t\t\t\t College of Engineering and Architecture \n\n";
cout << "\t\t\t\t\t\t\tPrepared by \n";
cout << "\t\t\t\t\t\t\t Group A4 \n";
cout << "\t\t\t\t\t\t\t BSCE 1B \n\n";
cout << "\t\t\t ---------------------------------------------------------------------- \n\n";
cout << "\t\t\t\t\t\t SIMPLE QUIZ USING WHILE LOOP \n\n";
int lives = 5;
string answer;
cout << "\t\t\t You have 5 lives to answer the question. \n";
while(lives != 0)
{
cout << "\t\t\t In which country is The Forbidden City located?" << endl;
cout << "\t\t\t Answer: ";
cin >> answer;
if(answer == "China")
{
cout << "\n\t\t\t Congratulations! You got the right answer." << endl;
break;
}
else
{
lives--;
cout << "\t\t\t You have " << lives << " lives left.\n\n";
}
if(lives == 0)
{
cout << "\n\t\t\t You lost.";
}
return 0;
}
OUTPUT:
NUMBERS TO MONTH PROGRAM
#include<iostream>
using namespace std;
int main()
{
cout << "\t\t\t ****************************************************************** \n";
cout << "\t\t\t\t\t Camarines Sur Polytechnic Colleges \n";
cout << "\t\t\t\t\t\t Nabua, Camarines Sur \n";
cout << "\t\t\t\t\t College of Engineering and Architecture \n\n";
cout << "\t\t\t\t\t\t\tPrepared by \n";
cout << "\t\t\t\t\t\t\t Group A4 \n";
cout << "\t\t\t\t\t\t\t BSCE 1B \n\n";
cout << "\t\t\t ---------------------------------------------------------------------- \n\n";
cout << "\t\t\t\t\t\t Numbers to Month Program \n\n";
int month;
cout<<"\t\t Enter the Month's number : ";
cin>>month;
switch (month)
{
case 1:
cout<<"\t\t\t\t\t\t\t January";
break;
case 2:
cout<<"\t\t\t\t\t\t\t Febrauary";
break;
case 3:
cout<<"\t\t\t\t\t\t\t March";
break;
case 4:
cout<<"\t\t\t\t\t\t\t April";
break;
case 5:
cout<<"\t\t\t\t\t\t\t May";
break;
case 6:
cout<<"\t\t\t\t\t\t\t June";
break;
case 7:
cout<<"\t\t\t\t\t\t\t July";
break;
case 8:
cout<<"\t\t\t\t\t\t\t August";
break;
case 9:
cout<<"\t\t\t\t\t\t\t September";
break;
case 10:
cout<<"\t\t\t\t\t\t\t October";
break;
case 11:
cout<<"\t\t\t\t\t\t\t November";
break;
case 12:
cout<<"\t\t\t\t\t\t\t December";
break;
}
return 0;
}
OUTPUT:
ENTERING YOUR AVERAGE GRADE USING IF-ELSE
STATEMENT
#include <iostream>
using namespace std;
int main()
{
cout << "\t\t\t ****************************************************************** \n";
cout << "\t\t\t\t\t Camarines Sur Polytechnic Colleges \n";
cout << "\t\t\t\t\t\t Nabua, Camarines Sur \n";
cout << "\t\t\t\t\t College of Engineering and Architecture \n\n";
cout << "\t\t\t\t\t\t\tPrepared by \n";
cout << "\t\t\t\t\t\t\t Group A4 \n";
cout << "\t\t\t\t\t\t\t BSCE 1B \n\n";
cout << "\t\t\t ---------------------------------------------------------------------- \n\n";
cout << "\t\t\t\t ENTERING YOUR AVERAGE GRADE USING IF-ELSE STATEMENT \n\n";
float average;
cout << "Enter your average grade: ";
cin >> average;
return 0;
}
OUTPUT:
ENTERING PASSWORD (STRING) USING IF-ELSE
STATEMENT
#include <iostream>
using namespace std;
int main()
{
cout << "\t\t\t ****************************************************************** \n";
cout << "\t\t\t\t\t Camarines Sur Polytechnic Colleges \n";
cout << "\t\t\t\t\t\t Nabua, Camarines Sur \n";
cout << "\t\t\t\t\t College of Engineering and Architecture \n\n";
cout << "\t\t\t\t\t\t\tPrepared by \n";
cout << "\t\t\t\t\t\t\t Group A4 \n";
cout << "\t\t\t\t\t\t\t BSCE 1B \n\n";
cout << "\t\t\t ---------------------------------------------------------------------- \n\n";
cout << "\t\t\t\t ENTERING PASSWORD (STRING) USING IF-ELSE STATEMENT \n\n";
if (password == correctPassword) {
cout << "Login successful!" << endl;
}
else {
cout << "Incorrect password. Please try again." << endl;
}
return 0;
}
OUTPUT:
BATTLESHIP USING ARRAY
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
// "1" is where the ship is located or the coordinates of the ship.
bool ships [4][4]=
{
{0,1,1,0},
{0,0,0,0},
{0,0,1,0},
{0,0,1,0}
};
int hits = 0;
int turns = 0;
// Display that you hit a ship and how many battleships are left
cout << "\t\t\t\t\t\t\tHit! " << (4-hits) << " left. \n\n";
} else {
//Display that they issed
cout << "\t\t\t\t\t\t\tMiss\n\n";
}
//Display how many turns the player has attempted
turns++;
}
cout << "\t\t\t\t\t\t\tVictory!\n";
cout << "\t\t\t\t\t\t\tYou won in " << turns << " turns";
return 0;
}
OUTPUT: