Skip to content

Instantly share code, notes, and snippets.

View Elsayegh's full-sized avatar

Wael Elsayegh Elsayegh

  • McCarthy Taylor Systems Ltd
  • Gloucester, United Kingdom
View GitHub Profile
@Elsayegh
Elsayegh / palindrome-checker
Created September 1, 2018 11:10
FreeCodeCamp JavaScript Algorithms and Data Structures Projects
*/Return true if the given string is a palindrome. Otherwise, return false.
A palindrome is a word or sentence that's spelled the same way both forward and backward, ignoring punctuation, case, and spacing.
Note
You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything into the same case
(lower or upper case) in order to check for palindromes.
We'll pass strings with varying formats, such as "racecar", "RaceCar", and "race CAR" among others.
@Elsayegh
Elsayegh / calcTotalMaxMinAVG.cpp
Created August 7, 2018 01:10
C++ 7-2 Calculating Rainfall - Total, Average, Min and Max values in Array
/*Write a program that lets the user enter the total rainfall for each of 12 months into an array of doubles.
The program should calculate and display the total rainfall for the year,the average monthly rainfall, and the months with the highest
and lowest amounts. */
#include <iostream>
#include <conio.h>
#include <ctime>
#include <iomanip>
#include <cstdlib>
#include <fstream>
@Elsayegh
Elsayegh / smallestLargestValueArrays.cpp
Created August 7, 2018 00:42
C++ 7-1 Finding Largest and Smallest Array Values in Array
/*Write a program that lets the user enter 10 values into an array. The program should then display the largest and smallest values
stored in the array. */
#include <iostream>
#include <conio.h>
#include <ctime>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <string>
@Elsayegh
Elsayegh / presentValue.cpp
Last active August 2, 2018 21:46
C++ Present Value (C++ functions)
/*Suppose you want to deposit a certain amount of money into a savings account and then leave it alone to draw interest
for the next 10 years. At the end of 10 years you would like to have $10000 in the account. How much would you need to deposit today
toi make that happen? You can use the following formula which is known as the percent value formula, to find out:
F
P = -----
(1 + r) (to the power of n)
P - Present value or amount that you need to deposit today
F - Future value that you want in the account (in this case, $10,000)
r - annual interest rate
@Elsayegh
Elsayegh / coinToss.cpp
Created August 2, 2018 14:24
C++ Simulating Coin Toss (C++ Functions and Loops)
/*Write a function named coinToss that simulates the tossing of a coin. When you call the function,
it should generate a random number in the range of 1 through 2. If the random number is 1,
the function should display "heads", if it is 2, it should display "tails". Demonstrate the function in a program that asks the user
how many times the coin should be tossed, and then simulates the tossing of the coin that number of times.
*/
#include <iostream>
#include <conio.h>
#include <ctime>
#include <iomanip>
@Elsayegh
Elsayegh / tempConversion.cpp
Created August 2, 2018 12:46
C++ Temperature Conversion (C++ Functions)
/*Write a function named celsius that accepts a Fahrenheit temperature as an argument. The function should return the temperature,
converted to Celsius.
Demonstrate the function by calling it in a loop that displays a table of the Fahrenheit temperatures 0 through 20
and their Celsius equivalents.
C = 5/9 * (F-32)
*/
#include <iostream>
#include <conio.h>
@Elsayegh
Elsayegh / calcKineticEnergy.cpp
Created August 1, 2018 14:54
C++ Calculate Kinetic Energy (C++ Functions)
/*Write a function named kineticEnergy that accepts an object's mass (in kg) and velocity (in m/s) as arguments.
The function should return the amount of kinetic energy that the object has.
Demonstrate the function by calling it in a program that asks the user to enter values for mass and velocity.
KE = 1/2 * m * v(to the power of 2)
*/
#include <iostream>
#include <conio.h>
#include <math.h>
@Elsayegh
Elsayegh / fallingDistance.cpp
Created August 1, 2018 14:29
C++ Calculating Falling Distance Using Functions and C++ Loops
/*Write a function named fallingDistance that accepts an object's falling time (in seconds) as an argument.
The function should return the distance, in meters, that the object has fallen during that time interval.
Write a program that demonstrates the function by calling it in a loop that passes the values 1 through 10 as arguments,
and displays the return value.
Formula: d = 1/2 * g * t(to the power of 2)
*/
#include <iostream>
@Elsayegh
Elsayegh / calcFewestAccidentsRoute.cpp
Last active August 1, 2018 14:30
C++ Calculate Values Using Functions and Switch Statements
/*Write a program that determines which of five geographic regions withing a major city (north, south, east, west, central)
had the fewest reported automobile accidents last year. It should have the following functions, which are called by main:
- int getNumAccidents() is passed the name of a region.
It asks the user for the number of automobile accidents reported in that region during the last year,
validates the input, then returns it. It should be called once for each city region.
- void findLowest() is passed the five accident totals.
It determines which is the smallest and prints the name of the region, along with its accident figure.
Input Validation: Do not accept negative values.
*/
@Elsayegh
Elsayegh / calculateSalesUsingFunctions.cpp
Last active August 1, 2018 14:31
C++ Calculate Profits Using Functions and Switch Statements
/*Write a program that determines which of a company's four division (NE, SE, NW, SW) had the greatest sales for a quarter.
It should include the following two functions, which are called by Main:
- double getSales() is passed the name of a division. It asks the user for a division's quarterly sales figure, validates the input,
then returns it. It should be called once for each division.
- void findHighest() is passed the four sales totals.
It determines which is the largest and prints the name if the high with its sale figure.
Input Validation: Do not accept dollar amounts less than $0.00
*/
#include <iostream>