C++代写:BA272 Item Sold Calculator



I recommend you do the program in the order specified. There is a chance that you will not finish. Get some things working so that you can at least earn partial credit.

Construct a simple program that projects revenue:

  1. Read thru all the criteria then create a test text file containing one set of test data depicting the finished application (including prompts and inputs, NOTE: you CAN use the sample data values provided in this document for the test file numbers)
  2. Create a method to accept integers from the user within a valid range (NOTE: Rob Miles has a similar method on Page 52 of your text)
    • a. Prompt the user with a string passed in as a method parameter so it can be used to prompt for all inputs
    • b. Us an appropriate loop so that the user is told when they supply and invalid value, and then are prompted again to enter the value
    • c. Name the method appropriately
    • d. Ensure the method uses Try/Catch or TryParse in order to handle invalid input properly
  3. In the Main method of your program:
    • a. Create two int variables: number-of-years, sales-growth-percentage-points. Name them appropriately.
    • b. Declare constants for min and max values for each of the two inputs (see values below), and a unit-price constant with a value of 9.99 (total 5 constants)
    • c. Be sure constants are named using the suggested ALL_UPPER_CASE format with underscore for spaces as described by Miles in the text.
    • d. Use your method from 1 above to prompt for and accept the following into your variables (be sure to use the constants from above for the min/max values appropriately):
      • i. “Number of Years” between 1 and 10
      • ii. “Sales Growth Rate” between -25 and 100%
    • e. Create variables to store values for: (hint some of these are monetary values, so use the correct type)
      • i. Items-sold-this-period (store the seed value of 10,000 in it - this is the initial value before the first year)
      • ii. Period-Revenue
      • iii. Total-Sold, Total-Revenue
  4. In the Main method of your program, print headings: “Year Items Sold Revenue”
  5. In the Main method of your program, create a for loop to forecast items sold and revenue as follows:
    • a. Have the loop process for the “Number of Periods” specified by the user
    • b. At the beginning of each pass through the loop compute:
      • i. Period Items Sold: (previous items-sold adjusted by the growth rate)
      • ii. Period Revenue: (items-sold * cost-per-item)
    • c. Use placeholder formatting to display the year, period items sold, and period revenue as shown below (including dollar signs, commas, and rounding to two decimal places for the revenue column and no decimal places for the items sold column)
      • i. Hint: you can use the same print format line for headings, details, and totals so they output with the same width "{0,6} {1,12} {2,12}" // This one is not quite right, but it's a start
    • d. In each pass through the loop, add the period amounts to the total amounts to accumulate the totals
  6. After displaying the rows for each period, display total items sold, and total revenue
  7. Be sure your program stops and leaves the results showing on the screen until the user presses enter
    Here is some sample output you can use to validate your output is correct (this is not a perfect formatted output, it is just here to help you get the math right)

See the Grading Criteria on the other side of this page.

Grading Criteria

  • (26) Requirement: Create an input method for capturing valid integers from the user
    • (4) The method returns an int data type
    • (4) The method only returns values between the min and max parameters
    • (4) The method asks again if the supplied answer is out of range
    • (4) The method displays a prompt passed in as a parameter
    • (4) Try/Catch or TryParse() was effectively used to keep the program from stopping when non-numeric input is provided
    • (4) When non-numeric data is entered, the method displays a message to the user and prompts the user for the data again
    • (2) Console.Write is used to ensure the user’s input shows next to the prompt
  • (16) Requirement: Effectively call the input method
    • (4) The input method is effectively used to capture the four user input values
    • (4) Min and Max values for inputs are declared as constants
    • (4) Constant names are capital letters with _ for spaces (e.g. MIN_PERIODS)
    • (4) Min and Max values passed into the method are used effectively
  • (50) Compute and display projection values
    • (5) Variable names meet class standards
    • (5) A working for loop is specified
    • (5) The for loop executes the correct number of periods (based on the user’s input)
    • (5) Period items sold, and revenue are correctly computed in each pass
    • (5) Variables for computed monetary values are of type decimal (even though input values are ints)
    • (5) The totals are correct (matching the provided example)
    • (5) The data and headings line up nicely (it doesn’t have to exactly match the example but it should be neat)
    • (5) Dollar signs, commas, and two decimal points are displayed for currency output values
    • (5) The program compiles, runs
    • (5) The program waits for the user to press enter at the end
  • (8) Test File: Write a test file with 1 test data set
    • (4) A test text file was provided with the solution with accurate data (can use the sample data)
    • (4) The test text file matches the programs output