Answer to Question #212287 in C++ for fazily

Question #212287

C++ PROGRAMMING

The "TRC Institute" records and monitors performance of three (3) machines over a period of four (4) days (l to 4) as shown in the Table 1, 2 and 3 respectively. The production ranges between 15.5 and 75.5 

Table 1- Machine "A" Production

Day 1 2 3 4

Array index 0 1 2 3

Production 15.5 25.5 27.5 60.5

Table 2- Machine "B" Production

Day 1 2 3 4

Array index 0 1 2 3

Production 50 45.5 25.5 18

Table 3- Machine "C" Production

Day 1 2 3 4

Array index 1 2 3 4

Production 35.5 65 71 74.5

Write a function using C++ statements called PrintChart() which takes three float arrays (valuel, value2, value3) and an integer (as day) as parameters. The function calls GetProduction and PrintBar functions to print the output as given below.

Sample Output.

Day 1

Machine A **

Machine B   ***** 

Machine C    ****


1
Expert's answer
2021-07-03T15:12:04-0400


#include <iostream>
using namespace std;
//We implement the GetProduction function which returns the cnt of *
int GetProduction(double pr[4], int ind)//pr-array of production ind-index (day) of table
{
    int one = (int)pr[ind] / 10;//The COUNT of tens in numbers
    int mod = (int)pr[ind] % 10;//COUNT
    if (pr[ind] - (int)pr[ind] * 1.0 >= 5)
        mod++;//Example 50.5 rounded 51
    if (mod >= 5)
        one++;//Example 56 rounded 6
    return one;


}
//Function PrintBar print **
void PrintBar(int cnt)
{
    for (int i = 0; i < cnt; i++)
        cout << "*";
    cout << endl;
}
//Function PrintChart()
void PrintChart(double prA[4], double prB[4], double prC[4], int day)
{
    cout << "Day " << day << endl;
    int cn_StarA = GetProduction(prA, day-1);
    int cn_StarB = GetProduction(prB, day - 1);
    int cn_StarC = GetProduction(prC, day - 1);
    cout << "Machine A "; PrintBar(cn_StarA);
    cout << "Machine B "; PrintBar(cn_StarB);
    cout << "Machine C "; PrintBar(cn_StarC);
    cout << endl;
}
int main()
{
    double prA[4] = { 15.5,25.5,27.5,60.5 };
    double prB[4] = { 50,45.5,25.5,18 };
    double prC[4] = { 35.5,65,71,74 };
    PrintChart(prA, prB, prC, 1);
    PrintChart(prA, prB, prC, 2);
    PrintChart(prA, prB, prC, 3);
    PrintChart(prA, prB, prC, 4);
    return  0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS