AFdN Calc v0.1

The times they are a-changin’.

This post seems to be older than 18 years—a long time on the internet. It might be outdated.

//Name: Andrew Ferguson
//Date: 2/20/2005
//Purpose: To create a calculator to calculate different things. w00t!

#include
#include

void getOption();

double bmi(double& pounds, double& inches);

void doBMI();

double poundsToKilograms(double& input);

void doPoundsToKilograms();

double feetToMeters(double& input);

void doFeetToMeters();

void quadratic(int& a, int& b, int& c, double& soln_1, double& soln_2);

void doQuadratic();

int gcf(int& a, int& b, int& c);

void doGCF();

double stardate(int& mont, int& day, int& year, int& hour, int& minute, int& second);

void doStardate();

int main()
{

getOption();
return 0;
}

void getOption(){
int choice;
cout << endl << "AFdN Calc v0.1" << endl << endl; do{ cout << "Your options are:" << endl << "1 - Calculate your BMI" << endl << "2 - Convert Pounds to Kilograms" << endl << "3 - Convert Feet to Meters" << endl << "4 - Solve a quadratic equation (no complex numbers)" << endl << "5 - Find the Greatest Common Factor for 3 numbers" << endl << "6 - Convert a date and time into Stardate format" << endl << "0 - Exit" << endl << endl << "Enter your choice: "; cin >> choice;
}while1; switch(choice) { case 1: doBMI(); getOption(); break; case 2: doPoundsToKilograms(); getOption(); break; case 3: doFeetToMeters(); getOption(); break; case 4: doQuadratic(); getOption(); break; case 5: doGCF(); getOption(); break; case 6: doStardate(); getOption(); break; case 0: break; } } double bmi(double& pounds, double& inches){ return (poundsToKilograms(pounds)/(feetToMeters(inches)*feetToMeters(inches))); } void doBMI(){ double pounds, inches; cout << "Enter your weight in pounds:"; cin >> pounds;
cout << "Enter your height in inches: "; cin >> inches;
cout << "You have a BMI of " << bmi(pounds, inches) << endl; } double poundsToKilograms(double& input){ return (input*0.454); } void doPoundsToKilograms(){ double pounds; cout << "Enter pounds: "; cin >> pounds;
cout << pounds << " lbs is " << poundsToKilograms(pounds) << " kg" << endl; } double feetToMeters(double& input){ return (input*0.3048/12); } void doFeetToMeters(){ double inches; cout << "Enter inches: "; cin >> inches;
cout << inches << " in is " << feetToMeters(inches) << " m" << endl; } void quadratic(int& a, int& b, int& c, double& soln_1, double& soln_2){ soln_1 =2)/(2*a); soln_2 =3)/(2*a); } void doQuadratic(){ int a,b,c; double soln_1, soln_2; cout << "Enter term 'a':"; cin >> a;
cout << "Enter term 'b':"; cin >> b;
cout << "Enter term 'c':"; cin >> c;
quadratic(a,b,c,soln_1,soln_2);
cout << "The solution to " << a << "x^2 + " << b << "x + " << c << " = 0 is x=" << soln_1 << " and x=" << soln_2 << endl; } int gcf(int& a, int& b, int& c){ { int remainder = b % a; if (remainder != 0) return gcf(remainder,a,c); remainder = c % a; if (remainder != 0) return gcf(remainder,a,c); return a; } } void doGCF(){ int a,b,c; cout << "Enter first term: "; cin >> a;
cout << "Enter second term: "; cin >> b;
cout << "Enter third term: "; cin >> c;
cout << "The Greatest Common Factor is " << gcf(a,b,c) << endl; } double stardate(int& month, int& day, int& year, int& hour, int& minute, int& second){ double nowTime =4*1000; return starTime; } void doStardate(){ int month, day, year, hour, minute, second; cout << "Enter the month: "; cin >> month;
cout << "Enter the day: "; cin >> day;
cout << "Enter the year: "; cin >> year;
cout << "Enter the hour: "; cin >> hour;
cout << "Enter the minute: "; cin >> minute;
cout << "Enter the second: "; cin >> second;
cout << endl << stardate(month, day, year, hour, minute, second); } [/code]

Download AFdN Calc v0.1

0
  1. choice > 7) || (choice < 0 

  2. -b)+sqrt((b*b)-(4*a*c 

  3. -b)-sqrt((b*b)-(4*a*c 

  4. 2322-1970)*365.2422*24*60*60)+(90*24*60*60); double itTime; int monthDays[] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; itTime = ((year-1970)*365.2422*24*60*60)+(monthDays[month]*24*60*60)+(day*24*60*60)+((hour-7)*60*60)+(minute*60)+second; double newTime = itTime - nowTime; double starTime = (newTime / (60*60*24*365.2422