SlideShare una empresa de Scribd logo
1 de 4
OptionExplicit
Submain()
DimpackageCode AsString
DimadultTicketsAsInteger
DimchildTicketsAsInteger
DimfirstClassChosenAsString
DimisFirstclassAsBoolean
DimticketCostAsInteger
DimdiscountedAsBoolean
packageCode = UCase(InputBox("Welcome tothe travel program!"&vbNewLine &"Pleaseselect
fromthe following:"&vbNewLine &"A.2 Day OuterBarrier Reef &Kuranda RainforestExperience"
& vbNewLine &"B.2 Day GreenIsland,KurandaTrain& Skyrail Adventure"&vbNewLine&"C.2 Day
Reef & Cape TribulationAdventure"))
Do While packageCode <>"A"AndpackageCode <> "B" AndpackageCode <> "C"
MsgBox ("Please enteraA,B or C")
packageCode = UCase(InputBox("Welcome tothe travel program!"&vbNewLine &
"Please selectfromthe following:"&vbNewLine&"A.2 Day OuterBarrierReef & Kuranda
RainforestExperience"&vbNewLine&"B.2 Day GreenIsland,KurandaTrain& Skyrail Adventure"&
vbNewLine&"C. 2 Day Reef & Cape TribulationAdventure"))
Loop
adultTickets=getQuantity("How manyadulttickets?")
childTickets=getQuantity("Howmanychildtickets?")
firstClassChosen=UCase(InputBox("Wouldyoulikefirstclasstickets?"&vbNewLine &"Enter
Y for yesor N for no"))
If firstClassChosen="Y" Then
isFirstclass=True
Else
isFirstclass=False
End If
ticketCost= calcTotalCost(packageCode,adultTickets,childTickets,isFirstclass)
If ticketCost>=500 Then
discounted=getDiscount()
End If
If discounted=True Then
ticketCost= ticketCost*0.8
MsgBox ("Youreceiveda20% discount")
End If
MsgBox ("The total cost: $" & ticketCost& vbNewLine &"Thankyoufor yourpurchase")
End Sub
FunctioncalcTotalCost(packageCode AsString,numAdultTicketsAsInteger,numChildTicketsAs
Integer,isFirstclassAsBoolean)AsInteger
DimadultCostAsDouble
DimchildCostAsDouble
DimtotalCostAsDouble
ConstADULT_TICKET_A = 200
ConstCHILD_TICKET_A = 150
ConstADULT_TICKET_B = 350
ConstCHILD_TICKET_B = 250
ConstADULT_TICKET_C = 400
ConstCHILD_TICKET_C = 275
ConstSALES_TAX= 0.1
ConstFIRST_CLASS_CHARGE= 0.2
If packageCode ="A" Then
adultCost=numAdultTickets*ADULT_TICKET_A
childCost=numChildTickets*CHILD_TICKET_A
ElseIf packageCode="B" Then
adultCost=numAdultTickets*ADULT_TICKET_B
childCost=numChildTickets*CHILD_TICKET_B
Else
adultCost=numAdultTickets*ADULT_TICKET_C
childCost=numChildTickets*CHILD_TICKET_C
EndIf
totalCost= adultCost+ childCost
totalCost= totalCost+ (totalCost*SALES_TAX)
If isFirstclass=True Then
totalCost= totalCost+ (totalCost*FIRST_CLASS_CHARGE)
End If
calcTotalCost= totalCost+ (totalCost*SALES_TAX)
End Function
FunctiongetDiscount() AsBoolean
DimluckyNumAsInteger
luckyNum= Int(10 - 1) * Rnd + 1
If luckyNum=7 Then
getDiscount=True
Else
getDiscount=False
End Function
FunctiongetQuantity(prompt) AsInteger
Dim value AsInteger
value = InputBox(prompt)
Do While value <0
MsgBox ("Please enteraquantityabove 0")
value = InputBox(prompt)
Loop
getQuantity=value
End Function

Más contenido relacionado

Destacado

Presentación Smart Gym 360º
Presentación Smart Gym 360º Presentación Smart Gym 360º
Presentación Smart Gym 360º hylennegonzalez
 
обзор изменений российского законодательства 21.12 25.12
обзор изменений российского законодательства 21.12 25.12обзор изменений российского законодательства 21.12 25.12
обзор изменений российского законодательства 21.12 25.12Olga Kravtsova
 
обзор изменений российского законодательства 05.10 09.10
обзор изменений российского законодательства 05.10 09.10обзор изменений российского законодательства 05.10 09.10
обзор изменений российского законодательства 05.10 09.10Olga Kravtsova
 
KAPITOLIO - Resumen de imágenes - Semana 11
KAPITOLIO - Resumen de imágenes - Semana 11KAPITOLIO - Resumen de imágenes - Semana 11
KAPITOLIO - Resumen de imágenes - Semana 11KAPITOLIO.info
 
Linea de tiempo (internet)
Linea de tiempo (internet)Linea de tiempo (internet)
Linea de tiempo (internet)RafaelDavid07
 

Destacado (9)

Marlene diapo-recuerdos
Marlene diapo-recuerdosMarlene diapo-recuerdos
Marlene diapo-recuerdos
 
Presentación Smart Gym 360º
Presentación Smart Gym 360º Presentación Smart Gym 360º
Presentación Smart Gym 360º
 
обзор изменений российского законодательства 21.12 25.12
обзор изменений российского законодательства 21.12 25.12обзор изменений российского законодательства 21.12 25.12
обзор изменений российского законодательства 21.12 25.12
 
обзор изменений российского законодательства 05.10 09.10
обзор изменений российского законодательства 05.10 09.10обзор изменений российского законодательства 05.10 09.10
обзор изменений российского законодательства 05.10 09.10
 
KAPITOLIO - Resumen de imágenes - Semana 11
KAPITOLIO - Resumen de imágenes - Semana 11KAPITOLIO - Resumen de imágenes - Semana 11
KAPITOLIO - Resumen de imágenes - Semana 11
 
Linea de tiempo (internet)
Linea de tiempo (internet)Linea de tiempo (internet)
Linea de tiempo (internet)
 
Andrew Tidsey CV
Andrew Tidsey CVAndrew Tidsey CV
Andrew Tidsey CV
 
Mis fotos elena
Mis  fotos elenaMis  fotos elena
Mis fotos elena
 
Educación familiar
Educación familiarEducación familiar
Educación familiar
 

Último

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Travel system vba code

  • 1. OptionExplicit Submain() DimpackageCode AsString DimadultTicketsAsInteger DimchildTicketsAsInteger DimfirstClassChosenAsString DimisFirstclassAsBoolean DimticketCostAsInteger DimdiscountedAsBoolean packageCode = UCase(InputBox("Welcome tothe travel program!"&vbNewLine &"Pleaseselect fromthe following:"&vbNewLine &"A.2 Day OuterBarrier Reef &Kuranda RainforestExperience" & vbNewLine &"B.2 Day GreenIsland,KurandaTrain& Skyrail Adventure"&vbNewLine&"C.2 Day Reef & Cape TribulationAdventure")) Do While packageCode <>"A"AndpackageCode <> "B" AndpackageCode <> "C" MsgBox ("Please enteraA,B or C") packageCode = UCase(InputBox("Welcome tothe travel program!"&vbNewLine & "Please selectfromthe following:"&vbNewLine&"A.2 Day OuterBarrierReef & Kuranda RainforestExperience"&vbNewLine&"B.2 Day GreenIsland,KurandaTrain& Skyrail Adventure"& vbNewLine&"C. 2 Day Reef & Cape TribulationAdventure")) Loop adultTickets=getQuantity("How manyadulttickets?") childTickets=getQuantity("Howmanychildtickets?") firstClassChosen=UCase(InputBox("Wouldyoulikefirstclasstickets?"&vbNewLine &"Enter Y for yesor N for no")) If firstClassChosen="Y" Then isFirstclass=True Else isFirstclass=False End If ticketCost= calcTotalCost(packageCode,adultTickets,childTickets,isFirstclass)
  • 2. If ticketCost>=500 Then discounted=getDiscount() End If If discounted=True Then ticketCost= ticketCost*0.8 MsgBox ("Youreceiveda20% discount") End If MsgBox ("The total cost: $" & ticketCost& vbNewLine &"Thankyoufor yourpurchase") End Sub FunctioncalcTotalCost(packageCode AsString,numAdultTicketsAsInteger,numChildTicketsAs Integer,isFirstclassAsBoolean)AsInteger DimadultCostAsDouble DimchildCostAsDouble DimtotalCostAsDouble ConstADULT_TICKET_A = 200 ConstCHILD_TICKET_A = 150 ConstADULT_TICKET_B = 350 ConstCHILD_TICKET_B = 250 ConstADULT_TICKET_C = 400 ConstCHILD_TICKET_C = 275 ConstSALES_TAX= 0.1 ConstFIRST_CLASS_CHARGE= 0.2 If packageCode ="A" Then adultCost=numAdultTickets*ADULT_TICKET_A childCost=numChildTickets*CHILD_TICKET_A
  • 3. ElseIf packageCode="B" Then adultCost=numAdultTickets*ADULT_TICKET_B childCost=numChildTickets*CHILD_TICKET_B Else adultCost=numAdultTickets*ADULT_TICKET_C childCost=numChildTickets*CHILD_TICKET_C EndIf totalCost= adultCost+ childCost totalCost= totalCost+ (totalCost*SALES_TAX) If isFirstclass=True Then totalCost= totalCost+ (totalCost*FIRST_CLASS_CHARGE) End If calcTotalCost= totalCost+ (totalCost*SALES_TAX) End Function FunctiongetDiscount() AsBoolean DimluckyNumAsInteger luckyNum= Int(10 - 1) * Rnd + 1 If luckyNum=7 Then getDiscount=True Else getDiscount=False End Function FunctiongetQuantity(prompt) AsInteger Dim value AsInteger
  • 4. value = InputBox(prompt) Do While value <0 MsgBox ("Please enteraquantityabove 0") value = InputBox(prompt) Loop getQuantity=value End Function