0

Hello, I'm new to programming and I have a simple project to plot a graph using gwin. The graph should just be a series of circles curving upwards on the y axis, the amount of plots should be defined by the user. I think I have everything almost correct but just can't find a few simple errors. any help would be much appreciated.

Sorry just read the forum guidelines and realise my post is riddled with annoyances!

#include "stdafx.h"
#include "gwin.h"

#include <iostream>
using namespace std;

// function declaration
double cube (double x);

int main ()
{

	// declare variables
	int count = 0;
	double height = Gwin.getHeight(); // establish maximum width
	double width = Gwin.getWidth(); // establish max height
	double scalex;
	double scaley;
	double maxvalue; // number of plots on graph
	double out_val;
	bool finish = false;

	Gwin.clear();

	Gwin.writeText(" How many points would you like to plot on the graph?");

	maxvalue = Gwin.getInt();

	scalex = double(width)/double(maxvalue);
	scaley = double(height)/ double(maxvalue);


	while (!finish)
	{
		if (int(count)==maxvalue)
		
		{
			finish = true;
		}
	
		else
		{
	
		out_val = cube(count);

		Gwin.circle ((scalex*count),(height-(scaley*cube(maxvalue))), 5);
		}
	}

	count = count+1;

	Keyboard.getch();


	return 0;


}

double cube (double x)
{
 return x*x*x;
}

cheers guys

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by Salem
0

I have now added a fill colour command before the draw circle command, thought this might solve my problem but it hasn't. the program is also freezing and I can only exit it using task manager.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.