Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2.P10 Sum of 10 Numbers READ ME (Set 1) . Notes: o Do not declare ten integers! Please! o Declare variables for pos sum, count

image text in transcribed
image text in transcribed
image text in transcribed
2.P10 Sum of 10 Numbers READ ME (Set 1) . Notes: o Do not declare ten integers! Please! o Declare variables for pos sum, count and average o Declare variables for non-pos sum, count and average o Declare variables for grand total and o Declare a single variable to read in the integers o Use setw() to line up the numbers and titles o use static_cast to convert sum to a double before dividing by count average otherwise, you will get an integer division. . Design: You will need a counting loop that goes from 0 to 10. Inside the loop, separate the positive and negative numbers using an if/else maintain the total of the positive and negative numbers in the if/else maintain the grand total in the body of the loop. outside the loop, print the report of the total of the positive, negative and the grand total. You should also count the number of the positive and negative numbers and print it at the end. Our in Class Pr Home Dropbox 2.00 READ ME (Set 1) Search Textbook Solutions |C Search Textbook SolutionsI C Indent e your code: This makes your code readable. e int maincint argc, char "argv) //comment describing purpose of this block while (xy) somethingO; //short comments explaining what is happening here sonethingelse); if (some error) //comment describing what this block is for do.correctO else //what does it mean to be here? continue.as usual O finalthingo: Comment your code thoroughly: . o At the top of the program: A comment block mus ndicate the name of the proseranner The purposte of the program, the expected output. o Above each function: a comment block above each function will xplain the purpose of the function, who the function calls, role of each argument. Function pre-conditions and post-conditions Line comments: every few lines before each "block" of code, you must have a line of comment that tells the reader what the purpose of the block is and how it works. This is especially important for any code whose purpose is not obvious upon first glance. Choose appropriate variable names: Someone with minimal famillarity with your project must understand the role and purpose of each variable: h, x, and y are not acceptable names. hr, or hour are good names. Do not use misspelled words as variable names. Do not make up your own abbreviations: hors is not a good replacement for hours, neither is mts for minutes Use constants when appropriate. You may not have number constants (such as 50, the capacity of a room, 16.75, hourly rate, or 35273.92, the number of ounces in a metric ton) in your code. You must declare constants for each of these numbers. Use "Magic Formula" to format your double numbers to two decimal points, unless otherwise stated Things To Watch out For: For every project in this set, break down your program into four blocks: . Declarations: this includes your constants . Input * processing e output Place a comment at the beginning of each block. The blocks must be separate. DO NOT do math in your cout statements. Each statement must be simple and clear. Avoid lengthy mathematical expressions Now, break processing into several smaller blocks (perhaps one statement each) State the purpose of each block before writing the code Wrap the code in a repeat loop so that the user can run the code as many times as they wish

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Which developments would therefore need to be initiated?

Answered: 1 week ago