Monday, 26 August 2013

Simple BMI Calculator

I was having a chat with a friend on how to host webpages freely on Google drive, which I decided to give a trial. Google drive is basically a cloud service from Google which allows registered users to save their files of up to 15GB size free online, there are many advantages of using it, and the best of all is you will never have issues about missing flash drives or corrupt ones and to add some spice to that, you can actually host your webpages on it too.
Google drive allows you to host webpages for free, the files for now can only in Html, CSS and JavaScript  which are fairly enough to create a fine webpage for demos and and maybe a start-up website when cash is hard to come by.Below is a link to a web app i created, written purely in JavaScript and hosted on Google drive, though not a fancy webpage, but very functional, as it can be used to calculate BMI (Body Mass Index), so u guys can check and calculate your BMI, who knows.

BMI CALCULATOR


https://googledrive.com/host/0B-EDcDbQRZRhV05jc3luQ1cxc0k/index.html#

Friday, 19 July 2013

Calculate your Heart beat rate using C++ (OOP)

Here is a little program used for getting the heart beat rate

Declaration of Methods (Heart.h)

// Program for calculating the Maximum Heart
#include <iostream>
#include <string>

using namespace std;

//Class for Heart Rate
class HeartRate {

public:
HeartRate (string, string, int, int, int); // constructor for the class

void setFirstName ( string ); // function for name
string getFirstName (); // function to return first name

void setLastName ( string ); // function for last name
string getLastName (); // function to return last name

void setDateOfBirth ( int, int, int); // Function to set date of birth
int getDateOfBirth ();

int getAge (); // function to get age
int getMaximumHeartRate (); // function to get Maximum Heart Rate
int getTargetHeartRate (); // function to get Target Heart Rate

private:

string fName; // Constructor's first name
string lName; // Constructor's last  name
int month; // Constructor's month
int day; // Constructor's day
int year; // Constructor's year
int yearToday; // Present year
int birthYear; // Year of birth

}; // end of function

Definition of the methods (HeartRate.cpp)

//Program definition for Heart beat rate
#include <iostream>
#include <string>
#include "HeartRate.h"


//While solving this question, thoughts about how best to create the constructor with having to had parameters
using namespace std;

HeartRate::HeartRate ( string fNamel, string lNamel, int monthl, int dayl, int yearl){

setFirstName (fNamel);
setLastName ( lName );
setDateOfBirth ( monthl, dayl, yearl);

}

void HeartRate::setFirstName ( string fNamel) { // function for set first name
fName = fNamel;
}

void HeartRate::setLastName ( string lNamel ){ // function for set last name
lName = lNamel;
}

void HeartRate::setDateOfBirth ( int monthl, int dayl, int yearl) { // function for set date of birth
month = monthl;
day = dayl;
year = yearl;
}

string HeartRate::getFirstName (){ // function to return first name
return fName;
}

string HeartRate::getLastName(){ // function to return last name
return lName;
}

int HeartRate::getDateOfBirth () { // function for date of birth
return 0;

}

int HeartRate::getAge () { // function to calculate age
int monthB, dayB, yearB, yearT;
cout << "Enter your date of birth in format: month day year" << endl;
cin >> monthB  >> dayB  >> yearB;

cout << "Enter current year: " << endl;
cin >> yearT;
yearToday = yearT;
birthYear = yearB;
cout << endl;
cout << "Your date of birth is: "<< monthB << "/" << dayB << "/" << yearB << endl;
cout << endl;
cout << "Your age is: " << (yearToday - birthYear) << endl;
return 0;

}

int HeartRate::getMaximumHeartRate () { //function for the maximum heart rate
cout << "Your maximum heart rate is: " << 220- (yearToday - birthYear) << endl;
return 0;
}

int HeartRate::getTargetHeartRate () { // function for the target heart rater
cout << "Your target heart rate range is: " << (0.5 * (220-(yearToday - birthYear))) << " - " << (0.85 * (220-(yearToday - birthYear))) << endl;
return 0;
}


Main Method (ex03_316.cpp)

//Program for the main

#include <iostream>
#include <string>
#include "HeartRate.h"

using namespace std;

int main () {
string  firstName, lastName;
HeartRate myHeartRate ( "*", "*", day(**), month(**), year (****));

cout << " Enter your Name " << endl;
cin >> lastName >> firstName;
cout << "Your name is: " << lastName  << " "<< firstName << endl;


myHeartRate.getAge ();
myHeartRate.getMaximumHeartRate ();
myHeartRate.getTargetHeartRate ();

return 0;
}

The asterisks are required inputs from the user in the formats expected as defined in the Declaration.