CSE Miami University Visual Studio C Programming Algorithm Code

User Generated

znetnerg0412

Programming

Miami University

CSE

Description

This is a C++ program question. Please use Visual Studio to complete this. Thank you.

Unformatted Attachment Preview

Create a program to be used in a coin sorting machine. The machine takes U.S. pennies, nickels, dimes, and quarters. The base specifications for these are as follows: penny diameter 19.05 mm weight 2.5 g nickel dime quarter 21.21 mm 17.91 mm 24.26 mm 5.0 g 2.268 g 5.670 g The machine is equipped with sensors that measure the diameter and weight of each coin in order to identify and count each type of coin. Since coins can be subject to wear and tear, each coin diameter and width is allowed a tolerance: +-2%. Your program must: a) b) c) d) declare constants for all constant values (base diameters, base widths, tolerance percentage) calculate and store the acceptable high and low values for each coin for diameter and width at the start, output the acceptable high and low values open and read coin data from the given data file and classify the coin based on the coin data, which is stored as a diameter and a weight, one coin on a line (partial file shown here) e) store the number of coins of each type as each is classified f) output the number and value of valid coins and the number of invalid coins, sample output shown below
Purchase answer to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

//introduce libraries#include <iostream>#include <fstream>using namespace std;//begin mainint main(){//declare variablesdouble tolerance=.02;int elements;cout << "How many coins are in the array?" << endl;cin >> elements;int diameterArray[elements];int weightArray[elements];double pennyHigh;double pennyLow;double pennyHighW;double pennyLowW;double nickelHigh;double nickelLow;double nickelHighW;double nickelLowW;double dimeHigh;double dimeLow;double dimeHighW;double dimeLowW;double quarterHigh;double quarterLow;double quarterHighW;double quarterLowW;int pennyAmount;int dimeAmount;int nickelAmount;int quarterAmount;int noneAmount;//tolerance inputpennyHigh=(tolerance+1)*19.05;pennyLow=(1-tolerance)*19.05;pennyHighW=(tolerance+1)*2.5;pennyLow...

Related Tags