I know the basics of vanilla c, but converting this compounded interest calculator over to the ti84 in ce proves to be difficult.
here's the code :
Code:
I've found that scanf and printf don't really work but found os_GetStringInput(); works well for scanf(); and the code that is default on TI-planet's "project builder" (printText(), works fine for printf(); :
Code:
could someone help me port this over to the ti84+ce?
this is what i've done so far :
Code:
here's the code :
Code:
#include <stdio.h>
#include <math.h>
int main ()
{
//define stuff
float principal;
float rate;
int times;
int years;
float roi;
float power;
//get starting values
printf("Principal? ");
scanf("%f",&principal);
printf("Rate? ");
scanf("%f",&rate);
printf("Years? ");
scanf("%d",&years);
printf("Times (per year)? ");
scanf("%d",×);
//do duh math sheiße
power = pow((1+(rate/times)),(years*times));
roi = principal*power;
//return values
printf("ROI: %f",roi);
return 0;
};
I've found that scanf and printf don't really work but found os_GetStringInput(); works well for scanf(); and the code that is default on TI-planet's "project builder" (printText(), works fine for printf(); :
Code:
void printText(const char *text, uint8_t xpos, uint8_t ypos)
{
os_SetCursorPos(ypos, xpos);
os_PutStrFull(text);
}
could someone help me port this over to the ti84+ce?
this is what i've done so far :
Code:
////////////////////////////////////////
// { PROGRAM NAME } { VERSION }
// Author:
// License:
// Description:
////////////////////////////////////////
/* Keep these headers */
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <tice.h>
/* Standard headers */
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Other available headers: stdarg.h, setjmp.h, assert.h, ctype.h, float.h, iso646.h, limits.h, errno.h */
#define INPUT_SIZE 10
/* uint8_t is an unsigned integer that can range from 0-255. */
/* It performs faster than just an int, so try to use it (or int8_t) when possible */
/* Put function prototypes here */
void printText(const char *text, uint8_t x, uint8_t y);
/* Put all your code here */
void main(void)
{
/*
float principal;
float rate;
int times;
int years;
float roi;
float power;
*/
char inputBuffer[INPUT_SIZE];
char principal[RESP_SIZE];
/*
const char rate[RESP_SIZE];
const char times[RESP_SIZE];
const char years[RESP_SIZE];
const char roi[RESP_SIZE];
const char power[RESP_SIZE];
*/
const char* one = "Principal? ";
/*
const char* two = "Rate? ";
const char* three = "Years? ";
const char* four = "Times (per year)? ";
const real_t fPrincipal;
*/
/* Clear the homescreen */
os_ClrHome();
/* Print a few strings */
printText(one, 0, 0);
os_GetStringInput("", inputBuffer, INPUT_SIZE);
rPrincipal = os_StrToReal(inputBuffer, rPrincipal);
printText(principal, 0, 2);
/*printText(two, 0, 3);
os_GetStringInput("", inputBuffer, INPUT_SIZE);
sprintf(principal, "Rate is %s.", inputBuffer);
printText(principal, 0, 4);*/
/* Wait for a key press */
while (!os_GetCSC());
}
/* Draw text on the homescreen at the given X/Y cursor location */
void printText(const char *text, uint8_t xpos, uint8_t ypos)
{
os_SetCursorPos(ypos, xpos);
os_PutStrFull(text);
}