# Help with switch statements!

**URL:** <https://forum.kirupa.com/t/help-with-switch-statements/635773>\
**Category:** programming\
**Created:** [January 6, 2017, 9:34pm UTC](https://forum.kirupa.com/t/help-with-switch-statements/635773 "2017-01-06T21:34:39Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [January 9, 2017, 10:34pm UTC](https://forum.kirupa.com/t/help-with-switch-statements/635773/21 "2017-01-09T22:34:28Z")

</div>

Yes, I didn’t spot that, “latte” is not recognised as “Latte”

cost is manipulated before multiplikation in the code.

(?) It seems you don’t understand \*=

cost \*= number;  
cost = cost \* number;  
cost = 1.8 \* 10;

---

<div class="post-metadata">

**Author:** ![Hassan\_Ahmed](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hassan_ahmed/32/7921_2.png) [@Hassan\_Ahmed](https://forum.kirupa.com/u/Hassan_Ahmed)\
**Post date:** [January 10, 2017, 10:52am UTC](https://forum.kirupa.com/t/help-with-switch-statements/635773/22 "2017-01-10T10:52:57Z")

</div>

But where did you get 1.8 from?

---

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [January 10, 2017, 2:07pm UTC](https://forum.kirupa.com/t/help-with-switch-statements/635773/23 "2017-01-10T14:07:13Z")

</div>

> [@Hassan\_Ahmed](#):
>
> if (number \> 5) { // discount  
> cost -= 0.2;  
> }

Same as with the multiplication.

“Latte”  
cost = 2.0,  
number = 10 (Discount)  
=\>

cost -= 0.2  
cost = cost - 0.2  
cost = 1.8

---

<div class="post-metadata">

**Author:** ![Hassan\_Ahmed](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/hassan_ahmed/32/7921_2.png) [@Hassan\_Ahmed](https://forum.kirupa.com/u/Hassan_Ahmed)\
**Post date:** [January 10, 2017, 6:34pm UTC](https://forum.kirupa.com/t/help-with-switch-statements/635773/24 "2017-01-10T18:34:22Z")

</div>

Guys I had my test today I was wandering if I can post the questions and you can reveal to me the answers so i can check against mine?

---

<div class="post-metadata">

**Author:** ![linusj](https://avatars.discourse-cdn.com/v4/letter/l/b2d939/32.png) [@linusj](https://forum.kirupa.com/u/linusj)\
**Post date:** [January 11, 2017, 8:22am UTC](https://forum.kirupa.com/t/help-with-switch-statements/635773/25 "2017-01-11T08:22:15Z")

</div>

I’m guessing, but with a test this early in the semester, isn’t it possible the teacher just want to check the overall knowledge and plan their teaching?

Seems kind of hard to start of like this and then increase the level from here?

---

<div class="post-metadata">

**Author:** ![kirupa](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kirupa/32/11616_2.png) [@kirupa](https://forum.kirupa.com/u/kirupa)\
**Post date:** [January 11, 2017, 4:48pm UTC](https://forum.kirupa.com/t/help-with-switch-statements/635773/26 "2017-01-11T16:48:08Z")

</div>

Yeah! Feel free to post the questions. Curious to see what is on it 🙂

[Previous page](https://forum.kirupa.com/t/help-with-switch-statements/635773.md?page=1)
