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 (12 months per year).
Input Validation:
Ensure the number of years entered is at least 1. If not, display an error message and prompt the user to enter a valid number.
Ensure that all sales amounts are non-negative. If a negative value is entered, display an error message and prompt the user to re-enter the value.
Calculations:
Calculate the total sales for each year.
Calculate the average monthly sales over the entire period.
Methods:
Value-Returning Method 1: Create a method that takes the total sales and the number of months as parameters, and returns the average sales.
Value-Returning Method 2: Create a method that validates user input (for years and sales amounts) and returns the validated value.
Non-Value-Returning 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.
Coding Assignment: Annual Sales Calculator

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!