Question: Coding Assignment: Annual Sales Calculator Objective: collecting and processing the data, the program will print the average monthly sales and total annual sales. Requirements: User
Coding Assignment: Annual Sales Calculator
Objective:
collecting and processing the data, the program will print the average monthly sales and total annual sales.
Requirements:
User Input:
Prompt the user to enter the number of years they want to calculate sales for.
For each year, prompt the user to enter the sales amount for each month months per year
Input Validation:
Ensure the number of years entered is at least If not, display an error message and prompt the user to enter a valid number.
Ensure that all sales amounts are nonnegative. If a negative value is entered, display an error message and prompt the user to reenter the value.
Calculations:
Calculate the total sales for each year.
Calculate the average monthly sales over the entire period.
Methods:
ValueReturning Method : Create a method that takes the total sales and the number of months as parameters, and returns the average sales.
ValueReturning Method : Create a method that validates user input for years and sales amounts and returns the validated value.
NonValueReturning Method: Create a method that prints the total sales and average sales in a formatted manner.
Output:
Format all dollar amounts to two decimal places.
Print the total sales for the entire period.
Print the average monthly sales.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
