Answer to Question #206477 in C++ for Sameen

Question #206477

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


Output

Day 1

Machine A**

Machine B*****

Machine C****


2)Write a function using c++ statements called PrintBar( ) which takes a float ( as production ) as a parameter. The function prints asterisks on the screen based on the production .

Note: 1 asterisk = 10 production units (round up the production units )


Input

Machine A Day 1 production 15.5

Output

**


1
Expert's answer
2021-06-13T07:05:51-0400
#include <iostream>
#include <math.h>
using namespace std;
float GetProduction(){
    float production;
    cin>>production;
    return production;
}
void PrintBar(float value){
    int c = ceil(value / 10);
    for(int i = 0; i < c; i++) cout<<"*";
}
void PrintChart(float value1 = 0, float value2 = 0, float value3 = 0, int day = 1){
    cout<<"Machine A Day "<<day<<" production "; value1 = GetProduction();
    cout<<"Machine B Day "<<day<<" production "; value2 = GetProduction();
    cout<<"Machine C Day "<<day<<" production "; value3 = GetProduction();


    cout<<"\nMachine A"; PrintBar(value1);
    cout<<"\nMachine B"; PrintBar(value2);
    cout<<"\nMachine C"; PrintBar(value3);
}
int main(){
    PrintChart();
    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