Tuesday, July 14, 2009

Trying to finish compute coin C++ program?

/***************************************...


* Program Name: Lab 12


* Author: Daniel Carr


* Date: 12 December 2007


* Course/Section: CSC-110-001


* Program Description: This program will tell what coins to give out for


* any amount of change from 1 cent to 99 cents.


*


*


**************************************...





/************************** Compiler Directives **********************/





#include %26lt;iostream%26gt;





using namespace std;





/*********************** Global Data Declarations ********************/





//None in this program.





/************************** Function Prototypes **********************/





//Sorts two numbers in ascending order


void input(int money);


int Calculatechange(int change);





int Calculatechange(int change);





void computecoin ( int%26amp; amount,int%26amp; coins, int denomiation);


void Output(int change, int quarters, int dimes, int nickles, int pennies);











/*************************************...


* Function Name: main


* Author: Daniel Carr


* Date: 8 November 2007


* Function Description:


*


* Pseudocode:


* Level 0


* -------


*


*


*


* Level 1


* -------


*


**************************************...





int main()


{


//Local variables


int money; //First user-entered number


int change; //Second user-entered number





/*************** Begin main Function Executables *****************/


//Variables





int quarters;


int dimes;


int pennies;


int nickles;








//Call function input


input(money);


//Call the function calculate


Calculatechange(change);


//Call function output


Output( change, quarters, dimes, nickles, pennies);














//Indicate to OS successful termination of program


return 0;





} //End main





/*************************************...


* Function Name: Input Money


* Author: Daniel Carr


* Date: 8 November 2007


* Function Description:


*


*


* Pseudocode:


* Level 0


* -------


* Enter amount of Money


*


* Level 1


* -------


* Enter amount of money


* Display "Enter amount of money (1-99)---%26gt;"


* Input Money


*


**************************************...


void input(int money)





//void inputmoney(float%26amp; x, //INOUT: First number to be sorted


// float%26amp; y) //INOUT: Second number to be sorted


{


//Local variables





cout %26lt;%26lt; "Enter amount of money (1-99)---%26gt;: ";


cin %26gt;%26gt; money;














} //End Input money





/*************************************...


* Function Name: Calculate Change


* Author: Daniel Carr


* Date: 8 November 2007


* Function Description: Calculate quarters, dimes, nickles, and pennies


*


*


* Pseudocode:


* Level 0


* -------


* Calculate Change


*


* Level 1


* -------


* Calcualte change


* Compute Quarters


* Compute Dimes


* Compute Nicklets and Pennies


* Level 2


* -------


* Compute Quarters


* Compute coin with Quarters, Change, and Q


* Compute Dimes


* Compute coin with Dimes, Change, and D


* Compute Nickles and Pennies


* Compute coin with Nickes Change and N,


*


*


*


*


*


*


*


**************************************...


int Calculatechange(int change)


{


//constants


const int q=25;


const int d=10;


const int n=5;


//arguements


int amount;


int denomiation;


int coins;





//Call the function computer coin


computecoin(amount,coins,denomiation)...











}





/*************************************...


* Function Name: Compute Coin


* Author: Daniel Carr


* Date: 8 November 2007


* Function Description: compute number of coin and amount left


*


*


* Pseudocode:


* level 0


* -------


* Compute number of coins and amount left


* level 1


* -------


* Compute number of coins and amount left


* coin=amount/demination


* amount = amount%demination


*


**************************************...


void computecoin ( int%26amp; amount,int%26amp; coins, int denomiation)


{


//Constistants





//Variables





//Arguements








coins = amount/denomiation;


amount= amount%denomiation;


amount %=denomiation;





























}





/*************************************...


* Function Name: Display Change


* Author: Daniel Carr


* Date: 8 November 2007


* Function Description: compute number of coin and amount left


*


*


* Pseudocode:


* level 0


* -------


* Display Change


* level 1


* -------


* Display Change


* display Change%26amp; "coints can be given" EOL


* display "-----------------------" EOL


* display quarters %26amp; "Quarter(s)" EOL


* display dimes %26amp; "Dimes(s)" EOL


* display nickles %26amp; "Nickles(s) EOL


* display pennies %26amp; "Pennie(s) EOL


*


**************************************...





void Output(int change, int quarters, int dimes, int nickles, int pennies)


{


//Aruments





//Consistants


//Variables





cout %26lt;%26lt; change %26lt;%26lt; "coins can be given" %26lt;%26lt; endl;


cout %26lt;%26lt; "-------------------------------------" %26lt;%26lt; endl;


cout %26lt;%26lt; quarters %26lt;%26lt; "quarter(s)" %26lt;%26lt; endl;


cout %26lt;%26lt; dimes %26lt;%26lt; "dimes(s)" %26lt;%26lt; endl;


cout %26lt;%26lt; nickles %26lt;%26lt; "Nickle(s) %26lt;%26lt; endl;


cout %26lt;%26lt; pennies %26lt;%26lt; "Pennie(s) %26lt;%26lt; endl;




















;}

Trying to finish compute coin C++ program?
U r missing quotes "...


"Nickle(s)"


"Pennie(s)"
Reply:Been through it a couple of times and the code seems ok but not sure about the way you've done your comments and pseudo code. C2001 is newline in constant %26gt;%26gt;





A string constant cannot be continued on a second line unless you do the following:





End the first line with a backslash.


Close the string on the first line with a double quotation mark and open the string on the next line with another double quotation mark.





http://msdn2.microsoft.com/en-us/library...





Can only assume the compiler is mistaking rems and pseudo for real code.


No comments:

Post a Comment