0% found this document useful (0 votes)
33 views10 pages

Final Project Template-CPE241A

The document outlines three C++ programming projects for students at National University - Laguna. The projects include a Student Grade Calculator, a Simple Banking System, and a Simple Voting System, each with detailed program code and functionality descriptions. The projects aim to enhance students' programming skills through practical applications in calculating grades, managing banking operations, and conducting voting processes.

Uploaded by

Chin Cuizon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views10 pages

Final Project Template-CPE241A

The document outlines three C++ programming projects for students at National University - Laguna. The projects include a Student Grade Calculator, a Simple Banking System, and a Simple Voting System, each with detailed program code and functionality descriptions. The projects aim to enhance students' programming skills through practical applications in calculating grades, managing banking operations, and conducting voting processes.

Uploaded by

Chin Cuizon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

NATIONAL UNIVERSITY – LAGUNA

Km. 53, National Highway, Brgy. Makiling, Calamba City, Laguna

SCHOOL OF ENGINEERING AND ARCHITECTURE


COMPUTER ENGINEERING DEPARTMENT
1st Trimester – 2023-2024

CPPROG2L – PROGRAMMING LOGIC AND DESIGN

Final Project

Submitted by:

Cuizon, Bhea Ellyssa G.

Go, Tythan Kennuel A.


CPE241A

Submitted to:

Engr. Mark Angelo T. Mercado, CCpE, MIT


Asst. Professor

November 4, 2024
Project 1: Student Grade Calculator
Project Overview:

Students will create a C++ program to calculate and display students' final grades based on their
exam and assignment scores.

Program Code:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class Student { // Define a class named Student to represent a student's information and scores
private:
string name;
double finalExam;
double quizzes[2]; // Two quizzes
double assignments[3]; // Three assignments

public: // Constructor to initialize the student's name and set the final exam score to 0
Student(string studentName) : name(studentName), finalExam(0) {}

void inputScores() { // Method to input scores for the student


cout << "Enter final exam score for " << name << ": ";
cin >> finalExam;

cout << "Enter scores for " << sizeof(quizzes) / sizeof(quizzes[0]) << " quizzes:\n";
for (int i = 0; i < 2; i++) {
cout << "Quiz " << (i + 1) << ": ";
cin >> quizzes[i];
}

cout << "Enter scores for " << sizeof(assignments) / sizeof(assignments[0]) << " assignments:\
n";
for (int i = 0; i < 3; i++) {
cout << "Assignment " << (i + 1) << ": ";
cin >> assignments[i];
}
cout << endl;
}

double calculateFinalGrade() { // Method to calculate the final weighted grade for the student
double quizzesTotal = 0.0;
for (double score : quizzes) {
quizzesTotal += score;
}
double quizzesAverage = quizzesTotal / 2;

double assignmentsTotal = 0.0;


for (double score : assignments) {
assignmentsTotal += score;
}
double assignmentsAverage = assignmentsTotal / 3;
return (0.5 * finalExam) + (0.2 * quizzesAverage) + (0.3 * assignmentsAverage);
}
// Method to determine the letter grade based on the final numeric grade
char calculateLetterGrade(double finalGrade) {
if (finalGrade >= 90) return 'A';
else if (finalGrade >= 80) return 'B';
else if (finalGrade >= 70) return 'C';
else if (finalGrade >= 60) return 'D';
else return 'F';
}

void displayResults() {
double finalGrade = calculateFinalGrade();
char letterGrade = calculateLetterGrade(finalGrade);

cout << left << setw(20) << name


<< setw(10) << fixed << setprecision(2) << finalGrade
<< setw(10) << letterGrade << endl;
}
};

int main() {
const int TOTAL_STUDENTS = 3;
Student students[TOTAL_STUDENTS] = {
Student("Student 1"),
Student("Student 2"),
Student("Student 3")
p
};
// Loop to input scores for each student
for (int i = 0; i < TOTAL_STUDENTS; i++) {
students[i].inputScores();
}

cout << "\nFinal Grades:\n";


cout << "---------------------------------------------------------\n";
cout << left << setw(20) << "Name" << setw(10) << "Weighted Avg" << setw(10) << "Letter
Grade" << endl;
cout << "---------------------------------------------------------\n";

for (int i = 0; i < TOTAL_STUDENTS; i++) {


students[i].displayResults();
}
cout << "---------------------------------------------------------\n";

return 0;
}

Project 2: Simple Banking System


Project Overview:

Students will create a C++ program to simulate basic banking operations, such as deposits, withdrawals,
and balance inquiries.
Program Code:
#include <iostream>
#include <string>
using namespace std;

// Function declarations

bool deposit(float &balance);

bool withdraw(float &balance);

bool checkBalance(float balance);

int main() {

// Variables to store account details

string accountNumber;

string accountHolderName;

float initialBalance;

int pin;

// Input user account details

cout << "Enter account number: ";

cin >> accountNumber;

cout << "Enter account holder name: ";

cin.ignore(); // Clear the input buffer

getline(cin, accountHolderName);

cout << "Enter initial balance: ";

cin >> initialBalance;

// Validate initial balance

if (initialBalance < 0) {

cout << "Initial balance cannot be negative. Exiting program." << endl;

return 1;

// Set up PIN
cout << "Set a 4-digit PIN for your account: ";

cin >> pin;

float balance = initialBalance;

int choice;

int enteredPin;

// Loop until the correct PIN is entered

while (true) {

cout << "\nEnter your PIN to access the banking menu: ";

cin >> enteredPin;

// Check if the entered PIN is correct

if (enteredPin != pin) {

cout << "Incorrect PIN. Access denied." << endl;

continue; // Ask for PIN again

// If the correct PIN is entered, show the banking menu

while (true) {

cout << "\n--- Banking Menu ---" << endl;

cout << "1. Deposit" << endl;

cout << "2. Withdraw" << endl;

cout << "3. Check Balance" << endl;

cout << "4. Exit" << endl;

cout << "Enter your choice: ";

cin >> choice;

switch (choice) {

case 1:

if (!deposit(balance)) {

cout << "Deposit failed." << endl;


}

break;

case 2:

if (!withdraw(balance)) {

cout << "Withdrawal failed." << endl;

break;

case 3:

checkBalance(balance);

break;

case 4:

cout << "Exiting program. Thank you!" << endl;

return 0; // Exit the program

default:

cout << "Invalid choice. Please try again." << endl;

return 0; // This will never be reached

// Function to handle deposits

bool deposit(float &balance) {

float amount;

cout << "Enter amount to deposit: ";

cin >> amount;

if (amount > 0) {

balance += amount;

cout << "Deposit successful. Updated balance: ₱" << balance << endl;

return true;
} else {

cout << "Invalid deposit amount." << endl;

return false;

// Function to handle withdrawals

bool withdraw(float &balance) {

float amount;

cout << "Enter amount to withdraw: ";

cin >> amount;

if (amount > 0 && amount <= balance) {

balance -= amount;

cout << "Withdrawal successful. Updated balance: ₱" << balance << endl;

return true;

} else if (amount > balance) {

cout << "Insufficient funds. Withdrawal failed." << endl;

return false;

} else {

cout << "Invalid withdrawal amount." << endl;

return false;

// Function to check balance

bool checkBalance(float balance) {

cout << "Current balance: ₱" << balance << endl;

return true; // Always succeeds

}
Project 3: Simple Voting System
Project Overview:

Students will create a C++ program to simulate a voting system where users vote for their favorite
candidates, and the program tallies and displays the results.

Program Code:
#include <iostream>

#include <string>

using namespace std;

const int MAX_CANDIDATES = 3;

int main() {

// Array to hold candidate names and votes

string candidates[MAX_CANDIDATES];

int votes[MAX_CANDIDATES] = {0};

// Enter candidate names

cout << "Enter the names of " << MAX_CANDIDATES << " candidates:\n";

for (int i = 0; i < MAX_CANDIDATES; ++i) {

cout << "Candidate " << (i + 1) << ": ";

getline(cin, candidates[i]);

cout << "\nWelcome to the Voting System!\n";

// Voting process

while (true) {

// Display candidates

cout << "\nCandidates:\n";

for (int i = 0; i < MAX_CANDIDATES; ++i) {

cout << i + 1 << ". " << candidates[i] << " (Votes: " << votes[i] << ")\n";

}
int choice;

cout << "Enter the number of the candidate you want to vote for (1-" << MAX_CANDIDATES
<< "), or 0 to finish voting: ";

cin >> choice;

// Exit if the user chooses 0

if (choice == 0) {

break;

// Check if the choice is valid

if (choice < 1 || choice > MAX_CANDIDATES) {

cout << "Invalid choice. Please enter a number between 1 and " << MAX_CANDIDATES <<
".\n";

continue;

// Record the vote

votes[choice - 1]++;

cout << "Thank you for voting for " << candidates[choice - 1] << "!\n";

// Display final results

cout << "\nVoting has ended. Here are the final results:\n";

for (int i = 0; i < MAX_CANDIDATES; ++i) {

cout << candidates[i] << " received " << votes[i] << " votes.\n";

// Determine and display the winner

int maxVotes = 0;

string winner;

for (int i = 0; i < MAX_CANDIDATES; ++i) {


if (votes[i] > maxVotes) {

maxVotes = votes[i];

winner = candidates[i];

cout << "The winner is: " << winner << " with " << maxVotes << " votes!\n";

return 0;

You might also like