Skip to content

Instantly share code, notes, and snippets.

@imryan
imryan / io.cpp
Created October 10, 2013 21:51
Reading/writing text files.
#include <iostream>
#include <fstream>
#include <string>
void w();
void r();
using namespace std;
int main()
{
@imryan
imryan / func.cpp
Created October 10, 2013 21:51
Playing with functions.
#include <iostream>
using namespace std;
double prodSum(double a, double b);
int main(int argc, char *argv[])
{
cout << "enter value for x and y:\n" << endl;
double x = 0;
@imryan
imryan / fill_array.cpp
Created October 10, 2013 21:50
Filling an array and looping through it.
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int homes[5];
for (int i = 0; i < 5; i++) {
cin >> homes[i];
}
@imryan
imryan / array.cpp
Last active December 25, 2015 05:39
Filling arrays and looping through them.
#include <iostream>
using namespace std;
void fillArray();
int main(int argc, char *argv[])
{
int homes[5];
int x = 10;
@imryan
imryan / args.cpp
Created October 10, 2013 21:49
Finding argument count in main method, and playing with a struct.
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout << "there are " << argc << " arguments:" << endl;
for (int narg = 0; narg < argc; narg++) {
cout << narg << " " << argv[narg] << endl;
}
@imryan
imryan / Mileage.java
Created October 9, 2013 17:20
Stupid mileage program.
import java.util.Scanner;
public class Mileage {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
double miles;
double gallons;
double mileage;
@imryan
imryan / PizzaCost.java
Created October 8, 2013 17:09
Determine cost to make pizza.
import java.util.Scanner;
public class PizzaCost {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
double size = 0.0;
double cost = 0.0;
@imryan
imryan / BirthdayGame.java
Last active December 25, 2015 00:29
Stupid birthday game. Makes no sense, but alright.
import java.util.Scanner;
public class BirthdayGame {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
double birthday = 0.0;
@imryan
imryan / Average.java
Created October 8, 2013 16:38
Calculates student average from 5 recent grades.
import java.util.Scanner;
public class Average {
public static void main(String[] args) {
// Declare variables
Scanner sc = new Scanner(System.in);
int grade1 = 0;
int grade2 = 0;
@imryan
imryan / Base.java
Last active December 24, 2015 22:19
Base conversion.
import java.util.*;
public class LabGrade
{
public static void main (String[] args)
{
int base; // the new base
int base10Num; // the number in base 10
int maxNumber; // the maximum number that will fit