Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to create a bar chart showing the average monthly mean temperatu

ID: 3850771 • Letter: W

Question

Write a program to create a bar chart showing the average monthly mean temperature for college Station from 2004 to 2013. The point of the exercise is to compute the size and location of the rectangles rather than explicitly hardcode that information. This means thinking about scale and offsets. The data is: 2013 48.3 deg F 2012 58.1 2011 54.5 2010 47.1 2009 51.1 2008 50.9 2006 55.2 2005 49.5 2004 56.9 Put it in an initializer list (use vector). Note that a good graphic will have the bars for each year clearly separated and a better graphic will have the tick mark for the year aligned with the center of the bar for that year. Write in C++. Please show me a output also.

Explanation / Answer

C++ Code for the given problem:

hw4pr.cpp

#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<dos.h>
#include<stdlib.h>

void rectDraw(int, int);

void main()

{
   //decalare the local variables
   int x, y, num, i;
  
   //delate the graphics driver
   int graphdriver = DETECT, graphmode;
   initgraph(&graphdriver, &graphmode, "..\bgi");
  
   //set the cloour
   setcolor(RED);
  
   //read the data size  
   cout<<"Input the number of data ebtries: ";
   cin>>num;
  
   //draw the x and y axis
   line(1,1,1,479);
   //x
   line(1,479,640,479);
  
  
   //initialize the bars
   for(int vi=1; vi<26;vi++)
   {
       outtextxy(40*vi,470,"|");
       outtextxy(1,479-40*vi,"-");
   }
  
  
   cout<<"Enter the data x and y values"<<endl;
  
   for(int vi=0; vi<num; vi++)
   {
       cin>>x>>y;
       y--;
       rectDraw(x*40, y*40);
   }
  
   getch();
   closegraph();
  
}

void rectDraw(int x, int y)
{
   setfillstyle(SOLID_FILL, CYAN);
   bar3d(x, 478, x, 430-y, 5, 1);
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote