Note that there are some explanatory texts on larger screens.

plurals
  1. POSpecial school code dealing with functions and return value issues
    primarykey
    data
    text
    <p>Here is a special problem we have been working on for my 100 level class and we recently added functions to the code. I can seem to figure exactly what to do to get this code to run. Also, my teacher says that the return value is not need for my variable getSID which is kind of confusing to me, any help is greatly appreciated!! Thank you. </p> <pre><code>#include &lt;iostream&gt; #include &lt;iomanip&gt; using namespace std; //here are the function prototypes for my problem int getSID(int &amp;); int getResidentStatus(int &amp;); double calculateTuition(double, double, double, double, double, double); double calculateTax(double &amp;); int main() {//declared variables char name[20], address[30], veteran, runningStart; int credits, SID, residency; double tuitionCost, taxDeductible, serviceFee, techFee, facilitiesFee, studentCenterFee, tuitionCostAndFees; cout &lt;&lt; "***********************************" &lt;&lt; endl; cout &lt;&lt; "* *" &lt;&lt; endl; cout &lt;&lt; "* Green River Community College *" &lt;&lt; endl; cout &lt;&lt; "* *" &lt;&lt; endl; cout &lt;&lt; "* 12401 SE 320th St. *" &lt;&lt; endl; cout &lt;&lt; "* Auburn, WA, 98092-3622 *" &lt;&lt; endl; cout &lt;&lt; "* *" &lt;&lt; endl; cout &lt;&lt; "* Phone (253) 833-9111 *" &lt;&lt; endl; cout &lt;&lt; "* *" &lt;&lt; endl; cout &lt;&lt; "***********************************" &lt;&lt; endl; cout &lt;&lt; "Enter name:"; cin.getline(name, 20); getSID(SID);//my teacher says this doesn't need to use a return value? getResidentStatus(residency); cout &lt;&lt; "Are you a veteran(y or n)?:"; cin &gt;&gt; veteran; while (!(veteran == 'y' || veteran == 'n')) { cout &lt;&lt; "Enter either 'y' for yes or 'n' for no: "; cin &gt;&gt; veteran; } cin.ignore(); cout &lt;&lt; "Are you involved in the running start program(y or n)?:"; cin &gt;&gt; runningStart; while (!(runningStart == 'y' || runningStart == 'n')) { cout &lt;&lt; "Enter either 'y' for yes or 'n' for no: "; cin &gt;&gt; runningStart; } cin.ignore(); cout &lt;&lt; "Enter home address(street address, and city):"; cin.getline(address, 30); cout &lt;&lt; "Enter number of credits:"; cin &gt;&gt; credits; serviceFee = credits*0.5; if (credits &lt;= 12) { techFee = credits * 5; } else if (credits&gt;12) { techFee = 60; } if (residency == 1 &amp;&amp; credits&gt;18) { tuitionCost = ((credits - 18)*268.26) + (149 * 8) + (278.84 * 10); } else if (residency == 1 &amp;&amp; credits&gt;10) { tuitionCost = ((credits - 10) * 149) + (278.84 * 10); } else if (residency == 1 &amp;&amp; credits &lt;= 10) { tuitionCost = (credits*278.84); } if (residency == 2 &amp;&amp; credits&gt;18) { tuitionCost = ((credits - 18)*109.26) + (53.68 * 8) + (119.84 * 10); } else if (residency == 2 &amp;&amp; credits&gt;10) { tuitionCost = ((credits - 10)*53.68) + (119.84 * 10); } else if (residency == 2 &amp;&amp; credits &lt;= 10) { tuitionCost = (credits*119.84); } if (residency == 3 &amp;&amp; credits&gt;18) { tuitionCost = ((credits - 18)*96.26) + (52.99 * 8) + (106.84 * 10); } else if (residency == 3 &amp;&amp; credits&gt;10) { tuitionCost = ((credits - 10)*52.99) + (106.84 * 10); } else if (residency == 3 &amp;&amp; credits &lt;= 10) { tuitionCost = (credits*106.84); } if (veteran == 'y'&amp;&amp;credits&gt;18) { tuitionCost = ((credits - 18)*96.26) + (52.99 * 8) + (96.26 * 10); } else if (veteran == 'y'&amp;&amp;credits&gt;10) { tuitionCost = ((credits - 10)*52.99) + (96.26 * 10); } else if (veteran == 'y'&amp;&amp;credits &lt;= 10) { tuitionCost = (credits*96.26); } if (runningStart == 'y') { tuitionCostAndFees = 0; } if (credits &lt;= 10) { facilitiesFee = 17.5 + (credits - 5)*3.5; } else facilitiesFee = 35; studentCenterFee = 25; calculateTuition(tuitionCostAndFees, tuitionCost, serviceFee, facilitiesFee, studentCenterFee, techFee);//This line seems to be the main problem as to why it won't run!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! calculateTax(tuitionCostAndFees); cout &lt;&lt; "Your name is: " &lt;&lt; name &lt;&lt; endl; cout &lt;&lt; "Your student identification number is: " &lt;&lt; SID &lt;&lt; endl; cout &lt;&lt; "Your address is : " &lt;&lt; address &lt;&lt; endl; cout &lt;&lt; "You are taking " &lt;&lt; credits &lt;&lt; " credits this quarter. " &lt;&lt; endl; cout &lt;&lt; "The total cost of your tuition is: $" &lt;&lt; tuitionCostAndFees &lt;&lt; endl; cout &lt;&lt; "The total tax deductible amount is: $" &lt;&lt; fixed &lt;&lt; setprecision(2) &lt;&lt; taxDeductible &lt;&lt; endl; system("pause"); return 0; }//function definitions int getSID(int &amp; SID) { cout &lt;&lt; "Enter your student identification number: " &lt;&lt; endl; cin &gt;&gt; SID; return SID; } int getResidentStatus(int &amp; residency) { cout &lt;&lt; "Are you an international student(1), non-washington resident(2) or washington resident(3)?: " &lt;&lt; endl; cin &gt;&gt; residency; while (!(residency == 1 || residency == 2 || residency == 3)) { cout &lt;&lt; "Enter either 1, 2 or 3"; cin &gt;&gt; residency; } return residency; } double calculateTuition(double &amp; tuitionCostAndFees, double &amp; tuitionCost, double &amp; serviceFee, double facilitiesFee, double &amp; studentCenterFee, double &amp; techFee) { tuitionCostAndFees = tuitionCost + serviceFee + facilitiesFee + studentCenterFee + techFee; return tuitionCostAndFees; } double calculateTax(double &amp; tuitionCostAndFees, double &amp; taxDeductible) { taxDeductible = tuitionCostAndFees*.125; return taxDeductible; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload