Question: using glut / opengl with graphics libary I need my program to displays the complete bar chart diagram. phics C + + Graphics Sales for
using glutopengl with graphics libary I need my program to displays the complete bar chart diagram. phics C Graphics
Sales for months
B
Sales Statistics
Max Sales $
Min Sales!
Parameter: sales Array that contains the sales data used for generating the bar char.
Parameter: nomonths Number of months ie entries of sales data to be processed. Should be between and inclusively.
For this example, month # corresponds to January, month # corresponds to February, and so on up to June corresponding to month # This program will next display the sales data in the form of a bar chart. The bar chart that this program generates consists of the following:
An xy axis
Rectangles representing the percentage of sales for a given month
The given months abbreviation displayed above its rectangle
An image and text used as the bar charts headingtitle
An informational box conwhich results in an integer value of Since the minimum allowable value for height is reset height to not
Observe that there is a very small green rectangle under the Feb heading that has a height of only pixel. This is due to the sales for the month of Feb is
Each months rectangle should be colored as follow:
January Red
February Green
March Blue
April Yellow
May Magenta
June Turquoise taining a summary of the sales data statisticsRH
This is what I have so far #include
#include "graphh
#include
using namespace std;
int getNoMonths;
void getSalesint sales int nomonths;
int getMaxint sales int nomonths;
int getMinint sales int nomonths;
double getAverageint sales int nomonths;
void displayResultsint sales int nomonths, int max, int min, int avg;
const int MAXMONTHS ;
int main
int nomonths ;
int salesMAXMONTHS;
int maxSale;
int minSale;
double avg;
int intAvg;
displayGraphics;
nomonths getNoMonths;
getSalessales nomonths;
maxSale getMaxsales nomonths;
minSale getMinsales nomonths;
avg getAveragesales nomonths;
intAvg intavg;
displayResultssales nomonths, maxSale, minSale, intAvg;
return ;
int getNoMonths
int months;
Prompt user until a valid input is entered
do
std::cout "Enter the number of months to process between and : ;
std::cin months;
Check if the input is valid
if months months
std::cout "Invalid entry. Please enter a number between and
;
while months months ;
return months;
void getSalesint sales int nomonths
for int i ; i nomonths; i
cout "Enter sales data for month i : ;
cin salesi;
int getMaxint sales int nomonths
int max sales;
forint i ; i nomonths; i
if salesi max
max salesi;
return max;
int getMinint sales int nomonths
int min sales;
forint i ; i nomonths; i
if salesi min
min salesi;
return min;
double getAverageint sales int nomonths
double total ;
double average ;
cout fixed setprecision endl;
for int i ; i nomonths; i
total salesi;
average staticcasttotal nomonths;
double roAvg pow;
average roundaverage roAvg roAvg;
return average;
void displayResultsint sales int nomonths, int max, int min, int avg
const int RECTWIDTH ;
const int DISTANCEBETWEEN ;
const char monthNamesMAXMONTHS "Jan", "Feb", "Mar", "Apr", "May", "Jun" ;
for int i ; i nomonths; i
int height staticcastdoublesalesi max;
if height
height ;
gout setPos "Max Sales: $ max endg;
gout setPos "Min Sales: $ min endg;
gout setPos "Avg Sales: $ avg endg;
gout setPos "Sales Statistics" endg;
gout setPos "Sales for nomonths months" endg;
gout setPos "Monthly" endg;
gout setPos "Sales" endg;
gout setPos "Months" endg;
displayBMPsalesbmp;
drawLine;
drawLine;
drawLine;
drawLine;
drawLine
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
