Alonzo, Eunice Sp.(Bscpe 1-1)_final Examination
Alonzo, Eunice Sp.(Bscpe 1-1)_final Examination
Alonzo, Eunice Sp.(Bscpe 1-1)_final Examination
if (option=="a"){
cout<<"\nHow much? ";
cin>>currency;
cout<<"\nWithdrawing "<< currency << endl;
}else if (option=="b"){
cout<<"\nHow much?";
cin>>currency;
cout<<"\nDeposits "<<currency;
}else if (option=="c"){
cout<<"\nYour balance is 2000";
}else if (option=="d"){
cout<<"\nEND";
}
}
return 0;
}
2. BMI CALCULATOR
#include <iostream>
double calculateBMI(double weight, double height) {
return weight / (height * height); }
int main() {
double weight, height;
std::cout << "Enter weight in kilograms: ";
std::cin >> weight;
std::cout << "Enter height in meters: ";
std::cin >> height;
double bmi = calculateBMI(weight, height);
std::cout << "BMI: " << bmi << std::endl;
return 0;
}
}
3. DICE GAME
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <thread>
#include <chrono>
int main() {
srand(time(0));
char playAgain;
do {
std::cout << "****************************************\n";
std::cout << "**********Welcome to the Game!**********\n";
std::cout << "****************************************\n\n";
std::cout << "Enter your name: ";
std::string pangalanmu;
std::cin >> pangalanmu;
std::cout << "\n****************************************\n";
std::cout << "*************Hello, " << pangalanmu << "!**************\n";
std::cout << "****************************************\n";
int lives = 3;
int score = 0;
do {
int guess1, guess2;
int dice1 = rand() % 6 + 1;
std::cout << "\nEnter two guess numbers on the dice (separated by space): ";
std::cin >> guess1 >> guess2;
std::cout << "Rolling";
for (int i = 0; i < 3; ++i) {
std::this_thread::sleep_for(std::chrono::milliseconds(500));
std::cout << ".";
std::cout.flush();
}
std::cout << "\n";
if (guess1 == dice1 || guess2 == dice1) {
std::cout << "\nCongratulations! You guessed correctly!\nThe dice showed: "<<
dice1 << "\n";
score++;
}else {
std::cout << "\nIncorrect guess. \nThe dice showed: " << dice1 <<" "<< "\n";
lives--;
if (lives > 0) {
std::cout << "\nYou have " << lives << " lives remaining.\n";
} else {
std::cout << "\nGame over. \nYour final score is: " << score << "\n";}
}
} while (lives > 0);
std::cout << "\nDo you want to try again? (y/n): ";
std::cin >> playAgain;
} while (playAgain == 'y' || playAgain == 'Y');
std::cout << "I hope you enjoy the dice game.\n";
return 0;
}