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;
}

>>but it doesn't want to work
by that I guess you mean it will not compile. What are the compile errors? What lines won't compile?

I know for a fact that lines 38 and 40 are wrong. -- using << instead of >>

also purchase and payment variables should probably be floats not ints

Another obvious problem -- you did not prototype function change(). It must be prototyped at the top of the program if you call it before it is coded. Just like variables have to be declared before used, functions have to be prototyped (or coded) before called.

anymore help also i have no idea what prototype is because we haven't learned it yet

>>but it doesn't want to work
by that I guess you mean it will not compile. What are the compile errors? What lines won't compile?

I know for a fact that lines 38 and 40 are wrong. -- using << instead of >>

also purchase and payment variables should probably be floats not ints

Another obvious problem -- you did not prototype function change(). It must be prototyped at the top of the program if you call it before it is coded. Just like variables have to be declared before used, functions have to be prototyped (or coded) before called.

>anymore help also i have no idea what prototype is because we haven't learned it yet
This is a function definition:

int change(float money, int onedollar, int twentyfivecent, int tencent, int fivecent, int penny)
{
  float temp;

  // ...

  return 0;
}

Note that it has no semicolon after the argument list but it defines a body. This is a prototype:

int change(float money, int onedollar, int twentyfivecent, int tencent, int fivecent, int penny);

Notice that it has no body, but it does have a semicolon after the argument list. A prototype is designed to declare the name, return type, and parameters of a function so that you can use it without having to define it first. The golden rule is that everything has to be declared before you can use it. That means this is very wrong, and shouldn't compile:

int main()
{
  foo();
}

int foo()
{
  return 0;
}

Why? Because foo wasn't declared before you used it. You can fix the problem by moving the definition before the use (because a definition is also a declaration):

int foo()
{
  return 0;
}

int main()
{
  foo();
}

But that's not always practical. This is where prototypes come in:

int foo();

int main()
{
  foo();
}

int foo()
{
  return 0;
}

Now foo is declared before you use it, and you can still define it wherever you want.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.