jdh1231 0 Newbie Poster

So, I am suppose to make the bar chart looking like the picture attached below using Array and for loops.

It suppose to output a bar chart (using "*") of temperatures for the hours.
Range of temperatures should be from -30 to 120.
Each * should have amount of 3 degrees and remainders should be rounded up to the appropriate number of stars.
On the left, it shows the degrees.

I need to have Main function, Heading Function, and Function for Graphing.

Below is my code, which is extremely messy, and wrong, but if I could have someone to guide me into a right way, that would be amazing.

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

	int num;
	int i;
	int hours[24]; // Creates an array holding the hours for input.
	double Temp[24]; // Declares an array to hold the inputted Temp.


void displayChart()
{
	for (int Temp <= -30 || Temp >= 120);
		{
			cin >> Temp;
			
			if (Temp > 120)
				cout << "TOO HOT" << endl;
				break;
			
			else if (Temp < -30)
				cout << "TOO COLD" << endl;
				break;
		}
		
		// Positive Temperatures
	for (int i = t; i > 0; i++)	
		if (t>0)
			cout << setw (11+t);
		else
			cout << setw (12+t);
		{
			for (int i = t; i > 0; i++)
				cout << "*";
			if (t_remainder < -1)
				cout << "*";
				cout << "|" << endl;
		}
		// Negative Temperatures
	else
		if (t<0)
			cout << setw (11+t);
		else
			cout << setw (12+t);
		{		
			for (int i = t; i <= -1; i++)
				cout << "*";
			if (t_remainder < -1)
				cout << "*";
				cout << "|" << endl;
		}

	cout << "--------------------------------------------------" << endl;

}

void headingChart();
	{
		cout<< "Temperature in a day" << endl;

		for (int i = 0; i < 5; i++) // Go through the above arrays to get the input.
			{
			cout << "Input the Temp for " << hours[i] << ":00 : ";
			cin >> Temp[i];
			}

	cout << "--------------------------------------------------" << endl; // Beginning of the Bar graph
	cout << setw(8) << "-30" << setw(11) << "0" << setw(11) << "30" << setw(11) << "60" 
		 << setw(11) << "90" << setw(11) << "120" << endl; // Heading
	}
	

void main()
{
displayChart();
headingChart();

system("pause");
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.