Jump to content



Photo

create if...elseif statement Visual basic

visual basic vb

  • Please log in to reply
58 replies to this topic

#46 abecedarian paradoxious

abecedarian paradoxious

    cell tech

  • Tech Issues Solved: 1
  • Joined: 04-November 07

Posted 29 August 2013 - 22:25

Doesn't cover the $7.50 cost if they are between 19 and 62.

Okay.

unsigned int intAge

// should be unsigned because negative ages aren't possible

// char is also permissible since people aren't likely to be > 255 years old

 

float decTicketPrice = 7.50   // default ticket price

 

if (intAge < 6) decTicketPrice = 0.00 // under 6 and you're in for free!

if (intAge > 5) and (intAge < 13) decTicketPrice += -4.00 // nice discount.

if (intAge > 12) and (intAge < 20) decTicketPrice += -3.00 // decent discount

if (intAge > 62) decTicketPrice += -2.00 // why the hate for senior citizens?

 

 

Still, no real reason for "else" conditions.

Start with the default and go.




#47 paxa

paxa

    Neowinian

  • Joined: 04-June 04
  • Location: so far away....nearly in the end of the world

Posted 29 August 2013 - 22:30

will not post the code. but instead give you a reference to in this case .net but still this series is a good reference to visual basic also.



#48 adrynalyne

adrynalyne

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 29-November 09

Posted 29 August 2013 - 22:31

Okay.

 

float decTicketPrice = 7.50

if (intAge <6 ) decTicketPrice = 0.00

if (intAge >5 ) and (intAge < 13) decTicketPrice += -4.00

if (intAge > 12) and (intAge <20) decTicketPrice += -3.00

if (intAge > 62) decTicketPrice += -2.00

 

 

Still, no real reason for "else" conditionals.

The reason is the assignment called for it.

 

Assignments are rarely designed to be the most efficient, but rather to teach a concept.

 

Not that it matters, the OP is clueless and wanted a handout.  And got it.



#49 abecedarian paradoxious

abecedarian paradoxious

    cell tech

  • Tech Issues Solved: 1
  • Joined: 04-November 07

Posted 29 August 2013 - 22:40

The reason is the assignment called for it.

 

Assignments are rarely designed to be the most efficient, but rather to teach a concept.

 

Not that it matters, the OP is clueless and wanted a handout.  And got it.

True, I suppose.

I always received 'extra credit' for thinking beyond the assignment though.



#50 adrynalyne

adrynalyne

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 29-November 09

Posted 29 August 2013 - 22:42

True, I suppose.

I always received 'extra credit' for thinking beyond the assignment though.

Heh, where I went, the instructors weren't allowed to give you extra credit.



#51 abecedarian paradoxious

abecedarian paradoxious

    cell tech

  • Tech Issues Solved: 1
  • Joined: 04-November 07

Posted 29 August 2013 - 22:45

Heh, where I went, the instructors weren't allowed to give you extra credit.

Mine weren't either, but gave 'privileges' to those who earned them.



#52 winlonghorn

winlonghorn

    Neowinian

  • Joined: 17-March 05
  • Location: Erie, PA

Posted 29 August 2013 - 22:48

Fill in the blank coding... Is that even real? LOL.

 

lol, that sounds interesting! :D



#53 adrynalyne

adrynalyne

    Neowinian Senior

  • Tech Issues Solved: 1
  • Joined: 29-November 09

Posted 29 August 2013 - 22:50

lol, that sounds interesting! :D

LOL...that is as bad as some of my instructors passing halfwits in my class that "kinda" got close to getting their program to compile.



#54 Top Qat

Top Qat

    Neowinian

  • Tech Issues Solved: 6
  • Joined: 09-July 04
  • Location: London, UK
  • OS: Windows 8.1u1 and Server 2012 R2u1
  • Phone: Samsung Galaxy S 3

Posted 29 August 2013 - 22:51

Alright, but now I want a for-loop to add to the TicketPrice in 0.5 increments. The for-loop must be called from all places that populate the final value.

Do it!

Nah CBA. :D



#55 winlonghorn

winlonghorn

    Neowinian

  • Joined: 17-March 05
  • Location: Erie, PA

Posted 29 August 2013 - 22:54

LOL...that is as bad as some of my instructors passing halfwits in my class that "kinda" got close to getting their program to compile.

 

Exactly! :)



#56 abecedarian paradoxious

abecedarian paradoxious

    cell tech

  • Tech Issues Solved: 1
  • Joined: 04-November 07

Posted 30 August 2013 - 00:03

"Close" only counts in horse shoes, hand grenades, loose women and nuclear war.



#57 Hum

Hum

    totally wAcKed

  • Tech Issues Solved: 5
  • Joined: 05-October 03
  • Location: Odder Space
  • OS: Windows XP, 7

Posted 30 August 2013 - 00:19

I've always used simple IF THEN statements.

 

Never saw the use for ELSEIF, WEND WHILE, etc.

 

Guess I'm dumb.



#58 FloatingFatMan

FloatingFatMan

    Resident Fat Dude

  • Tech Issues Solved: 1
  • Joined: 23-August 04
  • Location: UK

Posted 30 August 2013 - 06:22

I've always used simple IF THEN statements.

 

Never saw the use for ELSEIF, WEND WHILE, etc.

 

Guess I'm dumb.

 

No, you're Hum!



#59 Original Poster

Original Poster

    C++ n00b

  • Tech Issues Solved: 1
  • Joined: 15-July 08
  • Location: my room
  • OS: windows 7, backtrack 5, OSx 10.6

Posted 05 October 2013 - 23:01

if you cant do this...change course...