Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I really need the VBA code for this! the flowchart is below with the background info. is the following code that I wrote correct?

Hi I really need the VBA code for this! the flowchart is below with the background info.

is the following code that I wrote correct?

Sub PWW()

Dim P As Integer

Dim H As Integer

Dim RP As String

Dim MHP As Currency

Dim HHP As Currency

Dim DR As Double

Dim NMH As Integer

Dim NHH As Integer

Dim MHPE As Currency

Dim HHPE As Currency

Dim TMHP As Currency

Dim THHP As Currency

Dim TPBD As Currency

Dim DA As Currency

Dim TP As Currency

P = Range("E4").Value

H = Range("E6").Value

RP = Range("E8").Value

MHP = Range("J5").Value

HHP = Range("J6").Value

DR = Range("J8").Value

If RP = "yes" Then

DR = DR

Else

DR = 0

End If

If P > 39 Then

NMH = 0

NHH = 2

ElseIf P > 32 Then

NMH = 1

NHH = 1

ElseIf P > 23 Then

NMH = 2

NHH = 0

ElseIf P > 16 Then

NMH = 1

NHH = 1

Else

NMH = 1

NHH = 0

End If

MHPE = NMH * MHP

HHPE = NHH * HHP

If H = 2 Then

TMHP = 2 * MHPE

THHP = 2 * HHPE

ElseIf H = 4 Then

TMHP = 4 * MHPE

THHP = 4 * HHPE

ElseIf H = 6 Then

TMHP = 6 * MHPE

THHP = 6 * HHPE

End If

TPBD = TMHP + THHP

DA = TPBD * DR

TP = TPBD - DA

Range("D11").Value = NMH

Range("F11").Value = NHH

Range("D13").Value = MHPE

Range("F13").Value = HHPE

Range("D15").Value = TMHP

Range("F15").Value = THHP

Range("K12").Value = TPBD

Range("K14").Value = DA

Range("K16").Value = TP

End Sub

image text in transcribedimage text in transcribed

Prestige World-Wide Programming Project Assume you have just been hired by the manager of Prestige World-Wide (PWW), a small company located in Catalina. PWW specializes in providing helicopter tours in the California area. PWW holds tours for groups ranging from 1 to 46 people (including 1 person and 56 person tours), assume that the program user will know to only enter values between 1 and 56 people (inclusive). (This means you don't have to worry about "error-checking.") Your program should display the number of medium helicopters (NMH) needed and the number of heavy helicopters (NHH) needed, including the medium helicopter price extension (MHPE = NMH MHP) and heavy helicopter price extension (HHPE = NHH HHP). The program should also calculate if the customer is a repeat customer. If the customer is a repeat customer, they receive a discount. It should also display the total medium helicopter price (TMHP) and total heavy helicopter price (THHP), and the total price of the tour (TP). Note that the user will enter the number of people (P), and the number of hours (H), and if the customer is a repeat customer (RP) each time the program is run. But the pricing parameters are usually stable, so the values for these parameters will not be entered by the user each time. The visual basic code should accept the values of P, H, and RP into variables. It should do the same for the value of the pricing parameters from the pricing parameters cells as well. Two types of helicopters are available for use: medium helicopters (16 maximum tourists) and heavy helicopters (23 maximum tourists). PWW has two medium helicopters and two heavy helicopters; therefore, tour groups can use only combinations of the four helicopters at a time. PWW has three tour durations: 2, 4, and 6 hours. There are five tour options with each option using a different helicopter pairing as shown in Table 1. # of Helicopters Medium Heavy Price Per Hour Hourly Price Option Min and Max Tourists 100 100 min tourists max tourists min tourists max tourists min tourists max tourists 175 175 200 200 275 min tourists 100 1 max tourists 39 175 min tourists 40 max tourists 46 350 Table 1. PWW Combinations and Associated Pricing 350 0 46 To help you better understand the information summarized in the table, PWW provided you with a description of their pricing structure. For each helicopter, there is an hourly usage price that includes a pilot and tour guide. Each medium helicopter has an hourly price (MHP) of $100 and each heavy helicopter has an hourly price (HHP) of $175. Returning customers receive a discount of 10 percent. Your task is to create a program (based on the provided flowchart) that will pick the least-price helicopter combination. It should also calculate the final price for a tour group. Your program should accept the number of people (P), the tour duration (TD), the hourly rate for each helicopter size, the discount rate (DR), if the customer is a repeat customer (RP), and then calculate the price components and total price for the most efficient tour bussing option per day. Start Input P, H, RP MHP HHP. DR Variable List P (Integer) H (Integer) RP (String) MHP (Currency) HHP (Currency) DR (Double) NMH (Integer) NHH (Integer) MHPE (Currency) HAPE (Currency) TMHP (Currency) THHP (Currency) TPBD (Currency) DA (Currency) TP (Currency) DR DR + RP = "yes DR = 0 P> 39 P> 32 P> 23 R P> 16 NMH=0 NHH = 2 NMH = 1 NHH = 1 NMH = 2 NHH0 NMH = 0 NHH = 1 NMH = 1 NHH = 0 MHPE = NMH MHP HHPE = NHH HHP $ m TMHP2 MHPE THHP = 2* HHPE TMHP 4. MHPE THHP = 4 HHPE TMHP = 6 - MHPE THHP6 HHPE TPBD = TMHP. THHP DA = TPBD DR TP - TPBD - DA Output: NMH, NHH MHPE, HHPE, TMHP, THHP TPBD, DA, TP Prestige World-Wide Programming Project Assume you have just been hired by the manager of Prestige World-Wide (PWW), a small company located in Catalina. PWW specializes in providing helicopter tours in the California area. PWW holds tours for groups ranging from 1 to 46 people (including 1 person and 56 person tours), assume that the program user will know to only enter values between 1 and 56 people (inclusive). (This means you don't have to worry about "error-checking.") Your program should display the number of medium helicopters (NMH) needed and the number of heavy helicopters (NHH) needed, including the medium helicopter price extension (MHPE = NMH MHP) and heavy helicopter price extension (HHPE = NHH HHP). The program should also calculate if the customer is a repeat customer. If the customer is a repeat customer, they receive a discount. It should also display the total medium helicopter price (TMHP) and total heavy helicopter price (THHP), and the total price of the tour (TP). Note that the user will enter the number of people (P), and the number of hours (H), and if the customer is a repeat customer (RP) each time the program is run. But the pricing parameters are usually stable, so the values for these parameters will not be entered by the user each time. The visual basic code should accept the values of P, H, and RP into variables. It should do the same for the value of the pricing parameters from the pricing parameters cells as well. Two types of helicopters are available for use: medium helicopters (16 maximum tourists) and heavy helicopters (23 maximum tourists). PWW has two medium helicopters and two heavy helicopters; therefore, tour groups can use only combinations of the four helicopters at a time. PWW has three tour durations: 2, 4, and 6 hours. There are five tour options with each option using a different helicopter pairing as shown in Table 1. # of Helicopters Medium Heavy Price Per Hour Hourly Price Option Min and Max Tourists 100 100 min tourists max tourists min tourists max tourists min tourists max tourists 175 175 200 200 275 min tourists 100 1 max tourists 39 175 min tourists 40 max tourists 46 350 Table 1. PWW Combinations and Associated Pricing 350 0 46 To help you better understand the information summarized in the table, PWW provided you with a description of their pricing structure. For each helicopter, there is an hourly usage price that includes a pilot and tour guide. Each medium helicopter has an hourly price (MHP) of $100 and each heavy helicopter has an hourly price (HHP) of $175. Returning customers receive a discount of 10 percent. Your task is to create a program (based on the provided flowchart) that will pick the least-price helicopter combination. It should also calculate the final price for a tour group. Your program should accept the number of people (P), the tour duration (TD), the hourly rate for each helicopter size, the discount rate (DR), if the customer is a repeat customer (RP), and then calculate the price components and total price for the most efficient tour bussing option per day. Start Input P, H, RP MHP HHP. DR Variable List P (Integer) H (Integer) RP (String) MHP (Currency) HHP (Currency) DR (Double) NMH (Integer) NHH (Integer) MHPE (Currency) HAPE (Currency) TMHP (Currency) THHP (Currency) TPBD (Currency) DA (Currency) TP (Currency) DR DR + RP = "yes DR = 0 P> 39 P> 32 P> 23 R P> 16 NMH=0 NHH = 2 NMH = 1 NHH = 1 NMH = 2 NHH0 NMH = 0 NHH = 1 NMH = 1 NHH = 0 MHPE = NMH MHP HHPE = NHH HHP $ m TMHP2 MHPE THHP = 2* HHPE TMHP 4. MHPE THHP = 4 HHPE TMHP = 6 - MHPE THHP6 HHPE TPBD = TMHP. THHP DA = TPBD DR TP - TPBD - DA Output: NMH, NHH MHPE, HHPE, TMHP, THHP TPBD, DA, TP

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial Sorcery Magical Strategies To Create Real And Lasting Wealth

Authors: Jason Miller

1st Edition

1601632185, 9781601632180

More Books

Students also viewed these Finance questions