Skip to content

Instantly share code, notes, and snippets.

View Amali24's full-sized avatar

Andy Thomas Amali24

  • Boston, MA
View GitHub Profile
@Amali24
Amali24 / isTriangle().cpp
Last active June 8, 2016 22:29
Quick C++ Project for CIT-237 at BHCC
#include <iostream>
using namespace std;
// Validates numeric input
double getNum();
// Validates character is 'y' or 'n'
char getYorN();
// Returns true if three doubles make triangle, false otherwise
@Amali24
Amali24 / TimeCalculator.cpp
Last active June 8, 2016 23:30
CIT-237 Lab 4.1 - Given Seconds, calculates total minutes, hours, and days (and leftover seconds)
// CIT237 Lab exercise 4.1: Time Calculator
#include <iostream>
using namespace std;
int main()
{
// Constants
const int SECONDS_PER_MINUTE = 60; // Seconds in a minute
const int SECONDS_PER_HOUR = 3600; // Seconds in an hour
const int SECONDS_PER_DAY = 86400; // Seconds in a day
@Amali24
Amali24 / TextFileReadWrite.cpp
Last active June 16, 2023 17:09
Simple C++ File I/O Lab
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
// String variables for holding user inputted filenames
// And temp for temporarily holding a line of text from file
string fileNameIn, fileNameOut, temp;
// ifstream and ofstream for read/write
@Amali24
Amali24 / FilesIntoArrays.cpp
Created June 15, 2016 22:52
Reads ints from a text file into an array and displays various statistics about the numbers. Requires whitespace between integers.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int maxValue(int[], int);
int minValue(int[], int);
int sumValue(int[], int);
double avgValue(int[], int);
@Amali24
Amali24 / textSorter.cpp
Created June 20, 2016 23:42
Simple selection sort demonstration. Intended to sort names (one per line in a txt file)
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
void selectionSort(string[], int);
void showArray(string[], int);
int main() {
@Amali24
Amali24 / PtrArithmetic.cpp
Created June 22, 2016 23:33
Playing with pointer arithmetic
#include <iostream>
using namespace std;
int main() {
const int SIZE = 5;
cout << "Demonstrating a potential pitfall of pointer arithmetic...\n\n";
@Amali24
Amali24 / DynamicArrayWithPointers.cpp
Created June 29, 2016 15:34
Lab demonstrating dynamic memory allocation for arrays using pointers
#include <iostream>
#include <iomanip>
using namespace std;
int populateIntegerArray(int *arrayPtr, int arraySize);
void displayIntegerArray(int *arrayPtr, int arraySize);
int findMaximumInteger(int *arrayPtr, int arraySize);
double getNum();
int getInt();
@Amali24
Amali24 / MovieStruct.cpp
Created July 6, 2016 22:41
Demonstration of Structures in C++
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
struct MovieData {
string title;
string director;
int yearReleased;
double runningTime;
@Amali24
Amali24 / TextFileStruct.cpp
Last active July 20, 2016 23:04
Simple utility to count, display and output to file number of lines in a text file, byte offsets, etc
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct FileText {
int lineNumber; // Line number from original file
long long fileOffset; // Number of bytes from start line starts
int length; // Length of line
#include <iostream>
#include <ctype.h>
#include <string>
#include <fstream>
#include <sstream>
using namespace std;
int main()
{