Win a copy of Kotlin for Android App Development this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Trying to work out flight discounts in my program  RSS feed

 
Ranch Hand
Posts: 424
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys

if there are students and teachers flying to Kingston Jamaica for holiday and...

Flights are $297.67 per person travelling
There is one free teacher’s flight for every 20 students
There is no reduction if a free flight isn’t availed of
Any extra teachers pay full price

now the thing is that if there is no discount nothing must print out...so it only prints out the discount when a free flight is available and deducts it from the grand total at the end

so i was trying to work it out on paper first...

when dont you want reductions to print (ie when isnt there one)

a) when there is less than 20 students
b) when there are no teachers
any others?

here is the code i have written so far,but i just cant get my head around how this would work

 
jon ninpoja
Ranch Hand
Posts: 424
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
now this:



produces this:

how many students?100
how many teachers?100
95
end

its minuses 5 from teacher...and 5 free flights is what it is...i know im close
just cant see it.
 
jon ninpoja
Ranch Hand
Posts: 424
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actualFreeFlights = teachers - teachers + freeFlights

think this solved it...but please let me know if im right...or did i miss something

thanks
 
jon ninpoja
Ranch Hand
Posts: 424
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no doesnt work...please help
 
jon ninpoja
Ranch Hand
Posts: 424
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok think i have it now



tell me what you think...
 
Been there. Done that. Went back for more. But this time, I took this tiny ad with me:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!