Menu
Forum
General Car Audio
Subwoofers
Speakers
Amplifiers
Head Units
Car Audio Build Logs
Wiring, Electrical and Installation
Enclosure Design & Construction
Car Audio Classifieds
Home Audio
Off-topic Discussion
The Lounge
What's new
Search forums
Gallery
New media
New comments
Search media
Members
Registered members
Current visitors
Classifieds Member Feedback
SHOP
Shop Head Units
Shop Amplifiers
Shop Speakers
Shop Subwoofers
Shop eBay Car Audio
Log in / Register
Forum
Search
Search titles and first posts only
Search titles only
Search titles and first posts only
Search titles only
Log in / Join
What’s new
Search
Search titles and first posts only
Search titles only
Search titles and first posts only
Search titles only
General Car Audio
Subwoofers
Speakers
Amplifiers
Head Units
Car Audio Build Logs
Wiring, Electrical and Installation
Enclosure Design & Construction
Car Audio Classifieds
Home Audio
Off-topic Discussion
The Lounge
What's new
Search forums
Menu
Reply to thread
Forum
Off-topic Discussion
The Lounge
I need help with C++
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="MegaloJntariac" data-source="post: 6420007" data-attributes="member: 586438"><p>Here is where I am at now. I can get it to execute, but its:</p><p></p><p>- Not taking the fee out and posting it</p><p></p><p>- Its only changing bills but not with the coins, and if i input just a decimal it shows the coins, so i need it to do both.</p><p></p><p>Win32 Console file</p><p></p><p>[CODE]</p><p></p><p>#include &lt;iostream&gt;</p><p>#include &lt;iomanip&gt;</p><p>#include &lt;cmath&gt;</p><p>using namespace std;</p><p></p><p>void change(double, int&amp;, int&amp;, int&amp;, int&amp;, int&amp;, int&amp;);</p><p>void change(double, int&amp;, int&amp;, int&amp;, int&amp;); </p><p></p><p></p><p></p><p></p><p>bool validFee(double a)</p><p>{</p><p>return (a &lt;= 1000);</p><p>} // end Bool</p><p>void main()</p><p>{</p><p>int quar=0, dime=0, nick=0, penn=0, hunds = 0, fifts= 0, twents = 0, tens = 0, fives = 0, ones = 0;</p><p>double a; //price of check &lt; $1000.01</p><p></p><p>do</p><p>{</p><p>cout&lt;&lt;"Enter Check Amount: ";</p><p>cin&gt;&gt;a;</p><p>}</p><p>while (! validFee(a));</p><p></p><p>cout&lt;&lt;"Check Amount: "&lt;&lt;a&lt;&lt;endl;</p><p></p><p></p><p></p><p>change(a, hunds, fifts, twents, tens, fives, ones);</p><p>change(a, quar, dime, nick, penn);</p><p></p><p></p><p></p><p>}//endmain</p><p></p><p>double fee(double&amp; a)</p><p>{</p><p></p><p></p><p>if (a&gt;=0 &amp;&amp; a&lt;=100)</p><p>{</p><p> a = a - 5;</p><p> cout&lt;&lt;" Cashing Fee : $5.00"&lt;&lt;endl;</p><p> return a;</p><p>} // ends if</p><p>if (a&gt;100 &amp;&amp; a&lt;=500)</p><p>{</p><p> a = a - 15;</p><p> cout&lt;&lt;" Cashing Fee :$15.00"&lt;&lt;endl;</p><p> return a;</p><p>} // ends if</p><p></p><p>if (a&gt;500 &amp;&amp; a&lt;=1000)</p><p>{</p><p> a = a - 25;</p><p> cout&lt;&lt;" Cashing Fee :$25.00"&lt;&lt;endl;</p><p> return a;</p><p>} // ends if</p><p></p><p></p><p></p><p>}//end fee</p><p></p><p></p><p>void change(double a,int&amp; h,int&amp; f,int&amp; tw,int&amp; te,int&amp; fi,int&amp; o)</p><p>{</p><p>int c = static_cast&lt;int&gt;(a);</p><p>int hunds, fifts, twents, tens, fives, ones;</p><p></p><p>h=c/100;</p><p>c%=100;</p><p>f=c/50;</p><p>c%=50;</p><p>tw=c/25;</p><p>c%=25;</p><p>te=c/10;</p><p>c%=10;</p><p>fi=c/5;</p><p>c%=5;</p><p>o=c/1;</p><p></p><p>hunds = (h) * 100;</p><p>fifts = (f) * 50;</p><p>twents = (tw) * 20;</p><p>tens = (te) * 10;</p><p>fives = (fi) * 5;</p><p>ones = (o) * 1;</p><p></p><p></p><p></p><p>cout&lt;&lt;"Denominations Dispensed:"&lt;&lt;setw(15)&lt;&lt;endl;</p><p>cout&lt;&lt;"------------------------"&lt;&lt;setw(15)&lt;&lt;endl;</p><p>cout&lt;&lt;" # Amount"&lt;&lt;setw(15)&lt;&lt;endl;</p><p>cout&lt;&lt;" ------ -------- "&lt;&lt;setw(10)&lt;&lt;endl;</p><p>if(h&gt;0)</p><p> cout&lt;&lt;"Hundreds: "&lt;&lt;setw(15)&lt;&lt;h&lt;&lt;setw(10)&lt;&lt;hunds&lt;&lt;endl;</p><p>if(f&gt;0)</p><p> cout&lt;&lt;"Fifties: "&lt;&lt;setw(15)&lt;&lt;f&lt;&lt;setw(10)&lt;&lt;fifts&lt;&lt;endl;</p><p>if(tw&gt;0)</p><p> cout&lt;&lt;"Twenties: "&lt;&lt;setw(15)&lt;&lt;tw&lt;&lt;setw(10)&lt;&lt;twents&lt;&lt;endl;</p><p>if(te&gt;0)</p><p> cout&lt;&lt;"Tens: "&lt;&lt;setw(15)&lt;&lt;te&lt;&lt;setw(10)&lt;&lt;tens&lt;&lt;endl;</p><p>if(fi&gt;0)</p><p> cout&lt;&lt;"Fives: "&lt;&lt;setw(15)&lt;&lt;fi&lt;&lt;setw(10)&lt;&lt;fives&lt;&lt;endl;</p><p>if(o&gt;0)</p><p> cout&lt;&lt;"Ones: "&lt;&lt;setw(15)&lt;&lt;o&lt;&lt;setw(10)&lt;&lt;ones&lt;&lt;endl;</p><p></p><p>} // end change bills </p><p>void change(double a,int&amp; q,int&amp; d,int&amp; n,int&amp; p)</p><p>{ double chg = 1.00 - a;</p><p>int quar, dime, nick, penn;</p><p></p><p>int c = static_cast&lt;int&gt; (chg*100);</p><p></p><p>q=c/25;</p><p>c%=25;</p><p>d=c/10;</p><p>c%=10;</p><p>n=c/5;</p><p>p=c%5;</p><p></p><p>quar = (q) * 25;</p><p>dime = (d) * 10;</p><p>nick = (n) * 05;</p><p>penn = (p) * 01;</p><p></p><p>if(q&gt;0)</p><p> cout&lt;&lt;"Quarters: "&lt;&lt;setw(15)&lt;&lt;q&lt;&lt;setw(10)&lt;&lt;quar&lt;&lt;endl;</p><p>if(d&gt;0)</p><p> cout&lt;&lt;"Dimes: "&lt;&lt;setw(15)&lt;&lt;d&lt;&lt;setw(10)&lt;&lt;dime&lt;&lt;endl;</p><p>if(n&gt;0)</p><p> cout&lt;&lt;"Nickels: "&lt;&lt;setw(15)&lt;&lt;n&lt;&lt;setw(10)&lt;&lt;nick&lt;&lt;endl;</p><p>if(p&gt;0)</p><p> cout&lt;&lt;"Pennies: "&lt;&lt;setw(15)&lt;&lt;p&lt;&lt;setw(10)&lt;&lt;penn&lt;&lt;endl;</p><p></p><p></p><p></p><p></p><p>} // end change coins</p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p></p><p>[/CODE]</p><p>Here is what I am trying to get it to do:</p><p></p><p>- Prompts to ask for Check amount</p><p></p><p>- You Input check amount, if it is more than 1000 it loops back and asks you again</p><p></p><p>- at this point it should take a fee out based on the amount, also it will tell you how much the fee was</p><p></p><p>- now it should take whats left after the fee and change that into bills and coins, but our instructor wanted us to use an overload function to separate the bills and coins but using the same name.</p></blockquote><p></p>
[QUOTE="MegaloJntariac, post: 6420007, member: 586438"] Here is where I am at now. I can get it to execute, but its: - Not taking the fee out and posting it - Its only changing bills but not with the coins, and if i input just a decimal it shows the coins, so i need it to do both. Win32 Console file [CODE] #include <iostream> #include <iomanip> #include <cmath> using namespace std; void change(double, int&, int&, int&, int&, int&, int&); void change(double, int&, int&, int&, int&); bool validFee(double a) { return (a <= 1000); } // end Bool void main() { int quar=0, dime=0, nick=0, penn=0, hunds = 0, fifts= 0, twents = 0, tens = 0, fives = 0, ones = 0; double a; //price of check < $1000.01 do { cout<<"Enter Check Amount: "; cin>>a; } while (! validFee(a)); cout<<"Check Amount: "<<a<<endl; change(a, hunds, fifts, twents, tens, fives, ones); change(a, quar, dime, nick, penn); }//endmain double fee(double& a) { if (a>=0 && a<=100) { a = a - 5; cout<<" Cashing Fee : $5.00"<<endl; return a; } // ends if if (a>100 && a<=500) { a = a - 15; cout<<" Cashing Fee :$15.00"<<endl; return a; } // ends if if (a>500 && a<=1000) { a = a - 25; cout<<" Cashing Fee :$25.00"<<endl; return a; } // ends if }//end fee void change(double a,int& h,int& f,int& tw,int& te,int& fi,int& o) { int c = static_cast<int>(a); int hunds, fifts, twents, tens, fives, ones; h=c/100; c%=100; f=c/50; c%=50; tw=c/25; c%=25; te=c/10; c%=10; fi=c/5; c%=5; o=c/1; hunds = (h) * 100; fifts = (f) * 50; twents = (tw) * 20; tens = (te) * 10; fives = (fi) * 5; ones = (o) * 1; cout<<"Denominations Dispensed:"<<setw(15)<<endl; cout<<"------------------------"<<setw(15)<<endl; cout<<" # Amount"<<setw(15)<<endl; cout<<" ------ -------- "<<setw(10)<<endl; if(h>0) cout<<"Hundreds: "<<setw(15)<<h<<setw(10)<<hunds<<endl; if(f>0) cout<<"Fifties: "<<setw(15)<<f<<setw(10)<<fifts<<endl; if(tw>0) cout<<"Twenties: "<<setw(15)<<tw<<setw(10)<<twents<<endl; if(te>0) cout<<"Tens: "<<setw(15)<<te<<setw(10)<<tens<<endl; if(fi>0) cout<<"Fives: "<<setw(15)<<fi<<setw(10)<<fives<<endl; if(o>0) cout<<"Ones: "<<setw(15)<<o<<setw(10)<<ones<<endl; } // end change bills void change(double a,int& q,int& d,int& n,int& p) { double chg = 1.00 - a; int quar, dime, nick, penn; int c = static_cast<int> (chg*100); q=c/25; c%=25; d=c/10; c%=10; n=c/5; p=c%5; quar = (q) * 25; dime = (d) * 10; nick = (n) * 05; penn = (p) * 01; if(q>0) cout<<"Quarters: "<<setw(15)<<q<<setw(10)<<quar<<endl; if(d>0) cout<<"Dimes: "<<setw(15)<<d<<setw(10)<<dime<<endl; if(n>0) cout<<"Nickels: "<<setw(15)<<n<<setw(10)<<nick<<endl; if(p>0) cout<<"Pennies: "<<setw(15)<<p<<setw(10)<<penn<<endl; } // end change coins [/CODE] Here is what I am trying to get it to do: - Prompts to ask for Check amount - You Input check amount, if it is more than 1000 it loops back and asks you again - at this point it should take a fee out based on the amount, also it will tell you how much the fee was - now it should take whats left after the fee and change that into bills and coins, but our instructor wanted us to use an overload function to separate the bills and coins but using the same name. [/QUOTE]
Insert quotes…
Verification
Post reply
Forum
Off-topic Discussion
The Lounge
I need help with C++
Top
Menu
What's new
Forum list