程序代写代做代考 Programming Exercise 3-1

Programming Exercise 3-1

Programming Exercise 5-7

# Global constants for stadium seating

CLASS_A_SEATS = 20

CLASS_B_SEATS = 15

CLASS_C_SEATS = 10

# main module

def main():

# Local variables

countAseats = 0

countBseats = 0

countCseats = 0

incomeAseats = 0.0

incomeBseats = 0.0

incomeCseats = 0.0

# Get A count

countAseats = int(input(‘Enter count of A seats: ‘))

# Get B count

countBseats = int(input(‘Enter count of B seats: ‘))

# Get C count

countCseats = int(input(‘Enter count of C seats: ‘))

# Calculate A income

incomeAseats = countAseats * CLASS_A_SEATS

# Calculate B income

incomeBseats = countBseats * CLASS_B_SEATS

# Calculate C income

incomeCseats = countCseats * CLASS_C_SEATS

# Print income

showIncome(incomeAseats, incomeBseats, incomeCseats)

# The showIncome function accepts the income from class

# A, B, and C seats and displays the total income.

def showIncome(incomeAseats, incomeBseats, incomeCseats):

# Local variable

totalIncome = 0.0

# Calculate total income

totalIncome = incomeAseats + incomeBseats + incomeCseats

# Show results

print (“Income from class A seats: $”, \

format(incomeAseats, ‘.2f’), sep=”)

print (“Income from class B seats: $”, \

format(incomeBseats, ‘.2f’), sep=”)

print (“Income from class C seats: $”, \

format(incomeCseats, ‘.2f’), sep=”)

print (“Total income: $”, \

format(totalIncome, ‘.2f’), sep=”)

# Call the main function.

main()

main()

getAcount

(countAseats)

setAincome

(countAseats,

incomeAseats)

End

Declare

countAseats, countBseats, countCseats

incomeAseats, incomeBseats, incomeCseats

getAcount

(Ref inputAseats)

Return

Display “Enter

count of A

seats”

Input

inputAseats

showIncome

(incomeAseats, incomeBseats,

incomeCseats)

Return

Display “Income from A Seats: “,

incomeAseats

Display “Income from B Seats: “,

incomeBseats

Display “Income from C Seats: “,

incomeCseats

Display “Total Income: “,

totalIncome

Global Constant Real

CLASS_A_SEATS

CLASS_B_SEATS

CLASS_C_SEATS

showIncome

(incomeAseats,

incomeBseats,

incomeCseats)

setAincome

(countAseats,

incomeAseats)

Return

Set incomeAseats = countAseats

* CLASS_A_SEATS

getBcount

(countBseats)

getCcount

(countCseats)

setBincome

(countBseats,

incomeBseats)

setCincome

(countCseats,

incomeCseats)

getBcount

(Ref inputBseats)

Return

Display “Enter

count of B

seats”

Input

inputBseats

getCcount

(Ref inputCseats)

Return

Display “Enter

count of C

seats”

Input

inputCseats

setBincome

(countBseats,

incomeBseats)

Return

Set incomeBseats = countBseats

* CLASS_B_SEATS

setCincome

(countCseats,

incomeCseats)

Return

Set incomeCseats = countCseats

* CLASS_C_SEATS

Declare

totalIncome

Set totalIncome = incomeAseats +

incomeBseats + incomeCseats