伪代码预发布 Material IGCSE

Pseudocode Pre release Material IGCSE

我已经尝试了 IGCSE 预发布任务 (https://bestexamhelp.com/exam/cambridge-igcse/computer-science-0478/2017/0478-s17-pm-22.php) here is attached the documentation for the pseudocode(http://alongside.us/pseudocode/0478_pseudocode_guide.pdf) and I have run the program in VS code using a pcse extension which can be found here(https://github.com/virchau13/pcse-ext)。我已经成功地完成并完成了任务 1,但是我的第二个任务不会 运行。我无法识别错误,因为尽管只输出了一条消息,但程序根本没有 运行。任何帮助将不胜感激。

DECLARE SeniorCitizenNames: ARRAY[1:36] OF STRING
DECLARE individualCollectedAmount: ARRAY[1:36] OF REAL
DECLARE numSeniorCitizens: INTEGER
DECLARE Carers: INTEGER
DECLARE numPeople: INTEGER
DECLARE coachCost: INTEGER
DECLARE ticketCost: REAL
DECLARE mealCost: REAL
DECLARE totalCost: REAL
DECLARE costPerPerson: REAL
DECLARE totalAmountCollected: REAL
DECLARE hasMorePeople: BOOLEAN
DECLARE Carer1: STRING
DECLARE Carer2: STRING
DECLARE Carer3: STRING

OUTPUT "Enter Number of Senior Citizens:"
INPUT numSeniorCitizens // minimum 10 maximum 36

WHILE numSeniorCitizens < 10 OR numSeniorCitizens > 36 DO
    OUTPUT "INVALID. The number of Senior Citizens must be between 10 and 36 inclusive. 
    Please enter another number:"
    INPUT numSeniorCitizens // minimum 10 maximum 36
ENDWHILE
// Going to the trip
Carers <- 2
IF numSeniorCitizens > 24 
    THEN 
        Carers <- 3
ENDIF

numPeople <- numSeniorCitizens + Carers

IF numPeople >= 12 AND numPeople <= 16
    THEN 
        coachCost <- 150
        mealCost <- 14.00
        ticketCost <- 21.00
    ELSE
        IF numPeople >= 17 AND numPeople <= 26
            THEN
                coachCost <- 190
                mealCost <- 13.50
                ticketCost <- 20.00
            ELSE
                IF numPeople >= 27 AND numPeople <= 39
                    THEN
                        coachCost <- 225
                        mealCost <- 13.00
                        ticketCost <- 19.00
                ENDIF
        ENDIF
ENDIF

totalCost <- coachCost + mealCost * numPeople + ticketCost * numPeople
costPerPerson <- totalCost / numSeniorCitizens

totalAmountCollected <- 0

FOR count <- 1 TO numSeniorCitizens
    OUTPUT "Enter the names of the senior citizens and the amount they paid"
    INPUT SeniorCitizenNames[count]
    INPUT individualCollectedAmount[count]
    totalAmountCollected <- totalAmountCollected + individualCollectedAmount[count]
NEXT

OUTPUT "Are there more senior citizens to be added?"
INPUT hasMorePeople

WHILE numSeniorCitizens < 36 AND hasMorePeople == TRUE DO
    numSeniorCitizens <- numSeniorCitizens + 1
    OUTPUT "Enter the names of the senior citizens and the amount they paid"
    INPUT SeniorCitizenNames[numSeniorCitizens]
    INPUT individualCollectedAmount[numSeniorCitizens]
    totalAmountCollected <- totalAmountCollected + 
    individualCollectedAmount[numSeniorCitizens]

    OUTPUT "Are there more senior citizens to be added?"
    INPUT hasMorePeople
ENDWHILE

OUTPUT "the first carers name"
INPUT Carer1
OUTPUT "The second carers name is:"
INPUT Carer2

IF numSeniorCitizens > 24 
    THEN 
        Carers <- 3
        OUTPUT "The third carers name is:"
        INPUT Carer3
ENDIF

numPeople <- numSeniorCitizens + Carers

FOR count <- 1 TO numSeniorCitizens
    OUTPUT SeniorCitizenNames[count]
NEXT

OUTPUT "The first and second Carers names are", Carer1, "and", Carer2
IF numSeniorCitizens > 24 
    THEN 
        OUTPUT "The third carers name is", Carer3
ENDIF

OUTPUT "The total cost of this trip is $", totalCost // The totoal cost
OUTPUT "The cost per person for this trip is $", costPerPerson // The cost per person
OUTPUT "THe total amount collected is $", totalAmountCollected // amount of money collected 
by organiser

我不知道下面的伪代码是否能解决问题,但我稍微编辑了一些你原来的伪代码:

DECLARE SeniorCitizenNames: ARRAY[1:36] OF STRING
DECLARE individualCollectedAmount: ARRAY[1:36] OF REAL
DECLARE numSeniorCitizens: INTEGER
DECLARE Carers: INTEGER
DECLARE numPeople: INTEGER
DECLARE coachCost: INTEGER
DECLARE ticketCost: REAL
DECLARE mealCost: REAL
DECLARE totalCost: REAL
DECLARE costPerPerson: REAL
DECLARE totalAmountCollected: REAL
DECLARE hasMorePeople: BOOLEAN
DECLARE Carer1: STRING
DECLARE Carer2: STRING
DECLARE Carer3: STRING

OUTPUT "Enter Number of Senior Citizens:"
numSeniorCitizens <- USERINPUT // minimum 10 maximum 36


WHILE numSeniorCitizens < 10 OR numSeniorCitizens > 36:
    OUTPUT "INVALID. The number of Senior Citizens must be between 10 and 36 inclusive. Please enter another number:"
    numSeniorCitizens <- USERINPUT // minimum 10 maximum 36
ENDWHILE
// Going to the trip
Carers <- 2
IF numSeniorCitizens > 24 THEN:
    Carers <- 3
ENDIF

numPeople <- numSeniorCitizens + Carers

IF numPeople >= 12 AND numPeople <= 1 THEN: 
    coachCost <- 150
    mealCost <- 14.00
    ticketCost <- 21.00
    ELIF numPeople >= 17 AND numPeople <= 26 THEN:
            coachCost <- 190
            mealCost <- 13.50
            ticketCost <- 20.00
    ELIF numPeople >= 27 AND numPeople <= 39 THEN:
                    coachCost <- 225
                    mealCost <- 13.00
                    ticketCost <- 19.00
                ENDIF
        ENDIF
ENDIF

totalCost <- coachCost + mealCost * numPeople + ticketCost * numPeople
costPerPerson <- totalCost / numSeniorCitizens

totalAmountCollected <- 0

FOR count <- 1 TO numSeniorCitizens:
    OUTPUT "Enter the names of the senior citizens and the amount they paid"
    SeniorCitizenNames[count] <- USERINPUT
    individualCollectedAmount[count] <- USERINPUT
    totalAmountCollected <- totalAmountCollected + individualCollectedAmount[count]

OUTPUT "Are there more senior citizens to be added?"
hasMorePeople <- USERINPUT

WHILE numSeniorCitizens < 36 AND hasMorePeople == TRUE:
    numSeniorCitizens <- numSeniorCitizens + 1
    OUTPUT "Enter the names of the senior citizens and the amount they paid"
    SeniorCitizenNames[numSeniorCitizens] <- USERINPUT
    individualCollectedAmount[numSeniorCitizens] <- USERINPUT
    totalAmountCollected <- totalAmountCollected + 
    individualCollectedAmount[numSeniorCitizens]

    OUTPUT "Are there more senior citizens to be added?"
    hasMorePeople <- USERINPUT
ENDWHILE

OUTPUT "the first carers name"
Carer1 <- USERINPUT
OUTPUT "The second carers name is:"
Carer2 <- USERINPUT

IF numSeniorCitizens > 24 THEN:
    Carers <- 3
    OUTPUT "The third carers name is:"
    Carer3 <- USERINPUT
ENDIF

numPeople <- numSeniorCitizens + Carers

FOR count <- 1 TO numSeniorCitizens:
    OUTPUT SeniorCitizenNames[count]

OUTPUT "The first and second Carers names are", Carer1, "and", Carer2
IF numSeniorCitizens > 24 THEN: 
    OUTPUT "The third carers name is", Carer3
ENDIF

OUTPUT "The total cost of this trip is $", totalCost // The total cost
OUTPUT "The cost per person for this trip is $", costPerPerson // The cost per person
OUTPUT "THe total amount collected is $", totalAmountCollected // amount of money collected by organiser