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 / populationSizendGrowth.cpp
Created July 28, 2018 16:05
C++ Challenge (Population Size & Growth)
/*Write a program that will predict the size of a population of organisms.
The program should ask the user for the starting number of organisms, their average daily population increase (as a percentage),
and the number of days they will multiply. A loop should display the size of the population for each day.
Input Validation: Do not accept a number less than 2 for the starting size of the population.
Do not accept a negative number for average daily population increase.
Do not accept a number less than 1 for the number of days they will multiply.
*/
#include <iostream>
#include <conio.h>
@Elsayegh
Elsayegh / smallerHighestNumber.cpp
Created July 28, 2018 16:57
Finding Smallest & Largest Integers (C++ While Loops)
/*Write a program with a loop that lets the user enter a series of integers. The user should enter -99 to signal the end of the series.
After all the numbers have been entered, the program should display the largest and the smallest numbers entered.
*/
#include <iostream>
#include <conio.h>
#include <ctime>
#include <iomanip>
using namespace std;
@Elsayegh
Elsayegh / displaySalesGraph.cpp
Created July 28, 2018 19:15
C++ Display Bar Graph Using Nested For Loops and C++ Arrays
/* Write a program that asks the user to enter today's sales for five stores. the program should display a bar graph comparing each store
sales. Create each bar bar in the bar grap by displaying a row of asteriks. each asterisk should represnt a $100*/
#include <iostream>
#include <conio.h>
#include <ctime>
#include <iomanip>
using namespace std;
@Elsayegh
Elsayegh / guessNumber.cpp
Created July 28, 2018 20:40
C++ Guess The Number Game - Using Loops and If Statements
/*Write a program that generates a random number and asks the user to guess what the number is.
If the user's guess is higher than the random number, the program should display "Too high, try again".
If it is lower, it should display "Too low, try again".
The program should use a loop that repeats until the user correctly guesses the random number.
*/
#include <iostream>
#include <conio.h>
#include <ctime>
#include <iomanip>
@Elsayegh
Elsayegh / drawSquarePattern.cpp
Created July 28, 2018 20:53
C++ Display Square Pattern Using Nested For Loops
/* Write a program that asks the user for a positive integer no greater than 15.
The program should then display a square on the screen using the character 'X'.
The number entered by the user will be the length of each side of the square. So if user enters 5, we will display
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX
*/
@Elsayegh
Elsayegh / trianglePatternUsingLoops.cpp
Created July 28, 2018 21:24
C++ Display Triangle Patterns With Nested Loops
/*Write a program that uses a loop to display patterns below:
+
++
+++
++++
+++++
++++++
+++++++
++++++++
@Elsayegh
Elsayegh / sortNameAphabitically.cpp
Created July 29, 2018 13:00
C++ Comparing Strings From a Text File (Working with external text files)
/* Read data from external file and sort it alphabitically */
#include <iostream>
#include <conio.h>
#include <ctime>
#include <iomanip>
#include <cstdlib>
#include <fstream>
#include <string>
@Elsayegh
Elsayegh / calculateCostFunctions.cpp
Last active August 1, 2018 14:31
C++ Calculate Markup Cost With Functions
/*Write a program that asks the user to enter an item's wholesale cost and its markup percentage.
It should then display the item's retail price.
The program should have a function named calculateRetail that receives the wholesale cost and the markup percentage as arguments,
and returns the retail price of the item.
Input Validation: Do not accept negative values for either the wholesale cost of the item or the markup percentage.
*/
#include <iostream>
#include <conio.h>
#include <ctime>
@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>
@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.
*/