COSC6000 Homework 02

$30.00

Category: Tags: , , , You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (4 votes)

Part 1
Suppose we have several student’s scores and we want to develop a program that calculate
the average score.
Requirements:
User inputs score one by one.
The score is a positive or zero integer value.
When user inputs a negative value, the program calculates the mean score and is finalized.
The mean score is rounded off to the first decimal place.
This task could be broken down into the following procedures:
1. Initialize variables to store the number of student and the sum of score. (‘count=0’ and ‘sum=0’)
2. Start a loop
3. Get a student’s core. (cin >> score)
4. If the core is negative, exit from the loop. (go to 8)
5. Add the score to the sum. (sum += score)
6. Increment the counter. (count++)
7. Go back to 3
8. Compute the mean score. (mean = sum / count)
9. Print the result.
10. End.
Part 2
We develop “Buying Soda” code similarly with “Buying Pizza” code. (See Sample)
What size Soda is the best buy?
Which size gives the lowest cost per a little?
Soda sizes given in little.
Quantity of soda is based on the volume.
Buying Soda Problem Definion
Input:
Volume of two sizes of soda.
Cost of the same two sizes of soda.
4/23/2018 Homework 02
https://tulane.instructure.com/courses/2165899/assignments/13460471 2/2
Output:
Cost per a unit volume for each size of soda.
Which size is the best buy,
Based on lowest price per a unit volume,
If cost per a unit volume is the same, the smaller size will be the better buy.
Buying Soda Problem Analysis
Subtask 1
Get the input data for each size of soda
Subtask 2
Compute price per a unit volume for smaller soda
Subtask 3
Compute price per a unit volume for larger soda
Subtask 4
Determine which size is the better buy
Subtask 5
Output the results
* Declare and define a function to process Subtask 2 and 3.