CFP Activities PDF

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

CFP

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>

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 Sari sari store scenario (bool): \n\n";

bool BibiliNgHotdog = true;

if (BibiliNgHotdog)

cout << "\t\t\t\t\t NAKABILI AKO";

} else {

cout << "\t\t\t\t\t WALANG HOTDOG";

return 0;

}
OUTPUT:
SARI-SARI STORE SCENARIO (BOOLEAN & LOGICAL
OPERATORS)

#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 SARI-SARI STORE SCENARIO (BOOLEAN & LOGICAL OPERATORS) USING IF-ELSE STATEMENT
\n\n";

int quantity;
float price, totalCost;

cout << "Enter the quantity of the item: ";


cin >> quantity;

cout << "Enter the price of the item: ";


cin >> price;

totalCost = quantity * price;

if (quantity >= 10) {


totalCost *= 0.9; // apply 10% discount
}

if (totalCost > 100) {


totalCost *= 0.95; // apply additional 5% discount
}

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;

if (average >= 90 && average <= 100) {


cout << "Excellent work! You earned an A." << endl;
}
else if (average >= 80 && average < 90) {
cout << "Good job! You earned a B." << endl;
}
else if (average >= 70 && average < 80) {
cout << "Not bad! You earned a C." << endl;
}
else if (average >= 60 && average < 70) {
cout << "You need to work harder. You earned a D." << endl;
}
else if (average < 60) {
cout << "You failed the course. You earned an F." << endl;
}
else {
cout << "Invalid input. Please enter a valid average grade." << endl;
}

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";

string password, correctPassword = "passwordengineerk";

cout << "Enter your password: ";


cin >> password;

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;

cout << "\t\t\t\t\t\t\t ****************************************************************** \n";


cout << "\t\t\t\t\t\t\t Camarines Sur Polytechnic Colleges \n";
cout << "\t\t\t\t\t\t\t Nabua, Camarines Sur \n";
cout << "\t\t\t\t\t\t\t College of Engineering and Architecture \n\n";
cout << "\t\t\t\t\t\t\t Prepared 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\t\t\t\t ----------------------------------------------------------------------
\n\n";
cout << "\t\t\t\t\t\t\t BATTLESHIP USING ARRAY \n\n";

cout << "\t\t\t\t\t\t\t Welcome to a Battleship Game!!\n";


cout << "\t\t\t\t\t\t\t There are 4 Battleships that you need to hit.\n";
cout << "\t\t\t\t\t\t\t Enter the row and column number from 0 to 4 if you think \n";
cout << "\t\t\t\t\t\t\t the battleship is located in those coordinates \n";
cout << "\t\t\t\t\t\t\t If you successfully hit all ships, you win the game!\n";
cout << "\t\t\t\t\t\t\t Start Shooting!!!\n\n";
// This will allow the player to keep going until they win
while (hits < 4) {
int row, column;

cout << "\t\t\t\t\t\t\tSelecting Coordinates\n";

//Player will input the row


cout << "\t\t\t\t\t\t\tChoose a row number between 0 and 3: ";
cin >> row;

//Player will input the column


cout << "\t\t\t\t\t\t\tChoose a column number between 0 and 3: ";
cin >> column;

// This will check if there is a battleship in the given coordinates


if (ships[row][column]){
//If the player hits a battleship, remove it by setting the value to zero.
ships[row][column] = 0;

// Increase the hit counter


hits++;

// 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:

You might also like