{"id":6861,"date":"2021-11-21T13:40:42","date_gmt":"2021-11-21T13:40:42","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=6861"},"modified":"2021-11-21T13:41:31","modified_gmt":"2021-11-21T13:41:31","slug":"how-to-write-a-c-program-calculating-tax","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/how-to-write-a-c-program-calculating-tax\/23962.html","title":{"rendered":"How To Write a C++ Program Calculating Tax,"},"content":{"rendered":"<p>The program at the end should ask: How much was the meal? 44.50. the it should calculate the tax (.065) , calculate the tip (.15 of meal + tax) and calculate the total cost. Here&#8217;s my program:<\/p>\n<p>\/\/ This program asks the cost of the meal, calculates the tax, the tip and the total restaurant bill.<br \/>\n#include &lt;iostream&gt;<br \/>\nusing namespace std;<\/p>\n<p>int main()<br \/>\n{<br \/>\ndouble meal = 44.50; \/\/ meal<br \/>\ndouble tax = .0675*meal; \/\/ tax<br \/>\ndouble tip = .15*(meal+tax); \/\/ tip<br \/>\ndouble total = meal + tax + tip; \/\/ total<br \/>\ntax; \/\/computed tax<br \/>\ntip; \/\/computed tip<br \/>\ntotal; \/\/computed total<\/p>\n<p>\/\/ Get the cost of the meal.<br \/>\ncout &lt;&lt; &#8220;How much was the meal? &#8220;;<br \/>\ncin &gt;&gt; meal;<\/p>\n<p>\/\/ Get the tax.<br \/>\ncout &lt;&lt; &#8220;What was the tax? &#8220;;<br \/>\ncin &gt;&gt; tax;<\/p>\n<p>\/\/ Calculate the tax.<br \/>\ntax = meal*.0675 ;<\/p>\n<p>\/\/ Get the tip.<br \/>\ncout &lt;&lt; &#8220;What was the tip? &#8220;;<br \/>\ncin &gt;&gt; tip;<\/p>\n<p>\/\/ Calculate the tip.<br \/>\ntip = (meal+tax)*.15 ;<\/p>\n<p>\/\/ Get the total amount.<br \/>\ncout &lt;&lt; &#8220;What was the total amount? &#8220;;<br \/>\ncin &gt;&gt; total;<\/p>\n<p>\/\/ Calculate the total.<br \/>\ntotal = meal + tax + tip;<\/p>\n<p>\/\/ Display the meal charge. &lt;&lt; &#8220;The meal charge $&#8221; &lt;&lt; meal &lt;&lt;;endl;<\/p>\n<p>\/\/ Display the tax charge. &lt;&lt;&#8220;The tax charge $&#8221; &lt;&lt; tax &lt;&lt; endl;<\/p>\n<p>\/\/ Display the tip charge. &lt;&lt;&#8220;The tip charge $&#8221; &lt;&lt; tip &lt;&lt; endl;<\/p>\n<p>\/\/ Display the total. &lt;&lt;&#8220;The total amount spent $&#8221; &lt;&lt; total &lt;&lt; endl;<br \/>\nreturn 0;<\/p>\n<p>}<\/p>\n<p>Where did I go wrong? JJH &#8211; FL<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":5},"question-category":[55],"question_tags":[],"class_list":["post-6861","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/6861","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=6861"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=6861"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=6861"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=6861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}