trying to make a program to say the change due back after a purchase is made.
this is what i have so far but it doesn't want to work so i really could use some help please.
#include <iostream>
#include <string> // do not remove
/********************************************************************
* User Include Files *
********************************************************************/
#include "sapi.h" // do not remove
using namespace std;
/********************************************************************
* User Defined Constants *
********************************************************************/
/********************************************************************
* Function Prototypes *
********************************************************************/
void speech(string texttovoice);
/********************************************************************
* Function name: main *
* Date Written : *
* *
* Purpose: Provides an entry point to our program. *
* *
* Arguments: NONE *
* *
* Return Value: integer *
* *
********************************************************************/
int main ()
{
int money, onedollar, fiftycent, twentycent, tencent, fivecent, purchase, payment, penny;
Speech ("Enter the amount of purchase \n");
cin << purchase;
speech ("Enter the amount of payment \n");
cin << payment;
change(money, onedollar, twentyfivecent, tencent, fivecent, penny);
cout << "One Dollar: " << onedollar << endl;
cout << "twentyfive Cent: " << twentyfivecent << endl;
cout << "Ten Cent: " << tencent << endl;
cout << "five Cent: " << fivecent << endl;
cout << "pennys: " << penny << endl;
return 0;
}
int change(float money, int onedollar, int twentyfivecent, int tencent, int fivecent, int penny);
{
float temp;
temp = payment - purchase;
temp *= 100;
speech ("onedollar = temp/100");
temp = temp%100;
speech ("twentyfivecent = temp/25");
temp = temp%25;
speech("tencent = temp/10");
temp = temp%10;
speech( "fivecent = temp%5");
temp = temp/5;
speech( "penny = temp/1");
return 0;
}
/********************************************************************
* Function name: speech *
* Date Written : 9/2/2005 *
* *
* Purpose: To take a string of characters that has been passed in *
* as arguments and output them to the screen and the *
* speakers. Will only allow 1000 characters to be passed *
* in to form a word/sentence. *
* *
* Arguments: texttovoice the string to be outputted to the *
* screen and the speakers *
* *
* Return Value: NONE *
* *
* Written by: Dr Toni Logar and Roger Schrader *
* *
********************************************************************/
void speech( string texttovoice)
{
int i; // index used for conversion
WCHAR wstring[1000]; // used to hold convert string
ISpVoice* Voice = NULL; // The voice interface
// convert the string to a wide character string array
// and NULL terminate the string
i = 0;
while( i < (int)texttovoice.size() && i < 999)
{
wstring[i] = texttovoice[i];
i++;
}
wstring[i]='\0';
// Initialize COM
CoInitialize ( NULL );
// Create the voice interface object
CoCreateInstance ( CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice,
(void**)&Voice );
// Speak! Output the words to the screen
Voice->Speak(wstring,SPF_DEFAULT,NULL);
// Shutdown the voice
if ( Voice != NULL )
Voice -> Release ();
Voice = NULL;
// Shutdown COM
CoUninitialize ();
// Output the word to the screen
cout << texttovoice;
}