April 15, 2021, 03:22:09 AM

Author Topic: Case Statment Crisis!!!  (Read 8145 times)

0 Members and 1 Guest are viewing this topic.

Nexa

  • Guest
Case Statment Crisis!!!
« on: November 13, 2004, 09:01:24 PM »
 ???

Nexa

  • Guest
Re:Case Statment Crisis!!!
« Reply #1 on: November 13, 2004, 09:09:34 PM »
oops I forgot to post my message  ;D, but my crisis is how to build this case statment!  I need some help, I have a truly hard time understanding programing.

How would I go about constructing a case statement that has:
fixed salary workers
hourly salary workers at 40hrs a weeks with time and a half (1.5) for overtime
commision workers who receive $100 plus 4.3% of their gross weekly sales
and pieceworkers who receive only when the produce an item and that particular item is a pays a specific amout.

Actually a Switch statment not a case statement.

thanks
Nexa :-[

Offline Metgod

  • the deranged hacker
  • Administrator
  • Forum Hero
  • *****
  • Posts: 1116
  • Country:
  • Gender: Male
Re:Case Statment Crisis!!!
« Reply #2 on: December 02, 2004, 10:00:11 AM »
Hey,

Don't have much time here, and I am not checking the boards as much as I had even a couple weeks ago. I dont know if this will help, but here you go.. basic idea is this :

The syntax of a switch statement is :

Code: C++
  1. switch (var)
  2.    {
  3.     case <x>:
  4.          <code>
  5.          <break or return>
  6.     case <y>:
  7.           <code>
  8.           <break or return>
  9.     default:
  10.           <code>
  11.           <break or return>
  12.    }
  13.  

Where code can be any valid statement, including just returning or breaking right then. var is the variable you're checking against. Just remember to ALWAYS break or return at the end of EACH case, or it'll follow through to the next one! And you'll want to ALWAYS include a default statement (just in case the value isn't found earlier)

The <x>/etc MUST be constant.

So '1' is valid, and so is 1..

I hope that helps.
"My Terminal is my Soul"