Skip to content

Instantly share code, notes, and snippets.

View zachlatta's full-sized avatar
🏴‍☠️

Zach Latta zachlatta

🏴‍☠️
View GitHub Profile
It is a well-known fact that behind every good comet is a UFO. These UFOs often come to collect loyal supporters from here on Earth. Unfortunately, they only have room to pick up one group of followers on each trip. They do, however, let the groups know ahead of time which will be picked up for each comet by a clever scheme: they pick a name for the comet which, along with the name of the group, can be used to determine if it is a particular group's turn to go (who do you think names the comets?). The details of the matching scheme are given below; your job is to write a program which takes the names of a group and a comet and then determines whether the group should go with the UFO behind that comet.
Both the name of the group and the name of the comet are converted into a number in the following manner: the final number is just the product of all the letters in the name, where "A" is 1 and "Z" is 26. For instance, the group "USACO" would be 21 * 19 * 1 * 3 * 15 = 17955. If the group's number mod 47 is the
This may be a bit off-topic for this channel. I have a programmer who is above me who insists on using a code generator for a project. I experimented with the generator and I have a few issues with it. My biggest issueis that it generates messy code. It doesn't take advantage of C++ conventions and it clearly Java with a few tweaks to make it compile with a C++ compiler. I'm also afraid that some of the programmers on the team with less experience won't know what the underlying code does. Any ideas on how to express this to a superior?
public static void loadBooks(ArrayList<Book> books, String fileName)
{
try(Scanner scanner = new Scanner(new File(fileName)))
{
String currentLine;
String delims = ", ";
String[] tokens;
scanner.useDelimiter(", ");
@zachlatta
zachlatta / Character.cc
Created November 17, 2012 18:53
Character Class
#include "../Header/Character.h"
#include <iostream>
#include <fstream>
/********************
* PRIVATE METHODS *
********************/
void Character::setExperience(int experience)
{
@zachlatta
zachlatta / gist:3862630
Created October 10, 2012 01:37
Reading two files and outputting data
// Opens files
BufferedReader deposits = new BufferedReader(FileReader("Deposits.txt");
BufferedReader withdraws = new BufferedReader(FileReader("Withdrawals.txt");
// Reads from files and prints to console
String depositString;
String withdrawString;
double deposit;
double withdraw;
@zachlatta
zachlatta / SavingsAccount.java
Created October 9, 2012 00:48
SavingsAcccount Class
public class SavingsAccount {
private double annualInterestRate, balance, accumulativeInterest, accumulativeDeposits = 0, accumulativeWithdrawals = 0;
// Constructor
public SavingsAccount(double b)
{
balance = b;
}
// Mutators
@zachlatta
zachlatta / gist:3829950
Created October 3, 2012 21:26
Sleep function
#include <time.h>
void sleep(unsigned int mseconds)
{
clock_t goal = mseconds + clock();
while (goal > clock());
}
@zachlatta
zachlatta / gist:3773825
Created September 24, 2012 02:06
Bar Chart
import java.util.Scanner;
public class BarChart {
public static void main(String[] args)
{
double[] store = new double[5];
Scanner userInput = new Scanner(System.in);
@zachlatta
zachlatta / gist:3746613
Created September 18, 2012 23:06
Assignment: Internet Service Provider
/* An Internet service provider has three different subscription packages
* for its customers.
*
* Package A: For $9.95 per month 10 hours of access access are
* provided. Additional hours are $2.00 per hour.
*
* Package B: For $13.95 per month 20 hours of access are provided.
* Additional hours are $1.00 per hours.
*
* Package C: For $19.95 per month unlimited access is provided.
/* Write a program that lets a maker of chips and salsa keep track of their sales
for five different types of salsa they produce: mild, medium, sweet, hot, and
zesty. It should use two parallel five-element arrays: an array of strings that
holds the five salsa names and an array of integers that holds the number of jars
sold during the past month for each salsa type. The salsa names should be stored
using an initialization list at the time the name array is created. The program
should prompt the user to enter the number of jars sold for each type. Once this
sales data has been entered, the program should produce a report that displays
sales for each salsa type, total sales, and the names of the highest selling and
lowest selling products.