I'm having issues with my code
Write a program (Python) that determines which of a company’s
four divisions (Northeast, Southeast, Northwest, and Southwest) had
the greatest sales for a quarter. It should include the following
two functions, which are called by the main function.
double getSales() is passed the name of a
division. It asks the user for a division’s quarterly sales figure,
validates that the input is not less than 0, then returns it. It
should be called once for each division.
void findHighest() is passed the four
sales totals. It determines which is the largest and prints the
name of the high grossing division, along with its sales
figure.
Sample output:
def getsales(divisions): val = float(input("Enter %s division's quarterly sales figure: "(divisions))) if val>O: return val else: getSales(divisions) adef findHighest (divisionData, divisions): _max=0# store index of maximum sales figure for i in range(len(divisions): if divisionData>divisionData[_max]: _max=i print("%s is the high grossing division, with quarterly sales figures of %d" (divisions, (divisionData))) def main(): divisions=["Northeast", "Southeast", "Northwest", "Southwest"] divisionData=[] for i in range(len(divisions)): divisionData.append(getSales(divisions)) findHighest (divisionData, divisions)
Enter the quarterly sales for the Northeast division: 38 Enter the quarterly sales for the Southeast division: 90 Enter the quarterly sales for the Northwest division: 23 Enter the quarterly sales for the Southwest division: 12 The Southeast division had the highest sales this quarter. Their sales were $90.00
I'm having issues with my code Write a program (Python) that determines which of a company’s four divisions (Northeast,
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
I'm having issues with my code Write a program (Python) that determines which of a company’s four divisions (Northeast,
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!