Pages

Monday, January 23, 2006

Matlab rent calculator

Finally, I built a program for calculating the checks we have to write to eachother to pay the rent each month! Matlab, of course.


% Calculates rent for 3 peoples

clear all;
close all;

rents = 750; % Andrew pays that to the landlady
gas = input('How much was gas this time?'); % Rajay pays that
comcast = input('How much was Comcast this time?'); % Themo pays that
power = input('How much was power and water this time?'); % Rajay pays that

andrew_from_themo = rents;
andrew_from_rajay = rents;
rajay_from_andrew = (power+gas)/3;
rajay_from_themo = (power+gas)/3;
themo_from_andrew = comcast/3;
themo_from_rajay = comcast/3;

andrew_from_themo2 = andrew_from_themo - themo_from_andrew;
rajay_from_themo2 = rajay_from_themo - themo_from_rajay;
andrew_from_rajay2 = andrew_from_rajay - rajay_from_andrew;

andrew_from_themo3 = andrew_from_themo2 + rajay_from_themo2;
andrew_from_rajay3 = andrew_from_rajay2 - rajay_from_themo2;

disp(['Rajay, you pay $',num2str(andrew_from_rajay3),' to Andrew. Sucker!']);
disp(['Themo, you pay $',num2str(andrew_from_themo3),' to Andrew.']);

Categories