School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,049 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 4,527 people online right now. Registration is fast and FREE... Join Now!



Graphing Calculator App

Graphing Calculator App Making Algebra 2 App Rate Topic: -----

#1 AGRAC393  Icon User is offline

  • D.I.C Head
  • PipPip
  • Group: Members
  • Posts: 240
  • Joined: 13-May 09


Dream Kudos: 25

Posted 29 May 2009 - 03:48 PM

Hello,

I'm currently in 10th grade going into 11th in the fall! I have made a graphing calculator applet for geometry (my current math class) that has all of the formulas set so all you have to do is select the formula you want and it will ask you to input the certain part of the shape (area and surface area). For example
 cout <<"						Selected Shape: Circle\n";
				cout <<"\n";
				cout <<"Please enter the radius of the circle\n";
				cin >> num;
				cout <<"\n";
				cout <<"The Area Is: " << num * num * 3.14;
				cout <<"\n";
				cout <<"\n";
				system("PAUSE");
				system("CLS");


That works fine! I'm going into algebra 2 next year and I would like to make another applet for algebraic formulas. My question is, can explain how I can put the quadratic formula into my applet. I have not yet learned it but I would like to have it for next year! I know there is the 'ax^2 + bx + c = 0' way to do it... But from what I've read about it, it's not like geometric equations. I know, it's confusing the way I say it... So if anyone could clear it up for me!?!?!
Was This Post Helpful? 0
  • +
  • -


#2 apw5020  Icon User is offline

  • D.I.C Addict
  • PipPipPipPip
  • Group: Members
  • Posts: 585
  • Joined: 26-March 09


Dream Kudos: 0

Posted 29 May 2009 - 04:15 PM

You will need to #include <cmath>, which contains the necessary mathematical functions for the quadratic equation.

Check this link for help.

http://www.dreaminco.../snippet391.htm

This post has been edited by apw5020: 29 May 2009 - 04:16 PM

Was This Post Helpful? 0
  • +
  • -

#3 ABXG  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 24
  • Joined: 17-April 09


Dream Kudos: 0

Posted 29 May 2009 - 06:12 PM

You would simply ask the user for A, B, and C from the formula you gave. You would than run those values through these equations (quadratic formula produces two answers), you would of course have to filter out answers where the the result would be an imaginary number:

x1 = (-b + sqrt ((b^2) - 4ac)) / 2a

x2 = (-b - sqrt ((b^2) - 4ac)) / 2a

If (b^2) < 4ac your answer will be imaginary, I doubt you will be learning imaginary numbers in a high school math class.

You can find more on the quadratic formula here.

The quadratic equation is certainly one of the easier equations you will learn in algebra, although I am surprised you did not learn it in your Algebra 1 class. The quadratic formula was one of the first things I was taught in algebra.
Was This Post Helpful? 0
  • +
  • -

#4 AGRAC393  Icon User is offline

  • D.I.C Head
  • PipPip
  • Group: Members
  • Posts: 240
  • Joined: 13-May 09


Dream Kudos: 25

Posted 29 May 2009 - 06:22 PM

Thank you both for your help!
@awp5020: AWP, it always seems like you come to my rescue! Here is my attempt, I don't think it is right but it compiles...
#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	double num;
	double num2;
	double num3;
	double num4;
	char choice;
	for (;;){
	do {
	cout << "						  Aaron's Algebra Fromula Calc!\n";
	cout << "\n";
	cout << "Pick A Formula...\n";
	cout << "1. QUDRATIC FORMULA!!!\n";
	cout << "2. Other\n";
	cout << "3. Other\n";
	cin>>choice;
	} while ( choice < '1' || choice > '1' && choice != 'q');
	if (choice == 'q') break;
	switch (choice) {
		   case '1':
				cout << "Please input a\n";
				cin >> num;
				cout << "Please input x\n";
				cin >> num2;
				cout << "Please enter b\n";
				cin >> num3;
				cout << "Please enter c\n";
				cin >> num4;
				cout << "The Answer Is: " << num * (num2 * num2) + num3 * num + num4 << "\n";
				system("PAUSE");
				
}
				return 0;
}
}	


If it isn't right, can you please inform me on what is wrong? thank you!!!!
Was This Post Helpful? 0
  • +
  • -

#5 apw5020  Icon User is offline

  • D.I.C Addict
  • PipPipPipPip
  • Group: Members
  • Posts: 585
  • Joined: 26-March 09


Dream Kudos: 0

Posted 29 May 2009 - 08:00 PM

Nowhere do you actually use the quadratic formula that ABXG posted. Here is your code revised. I changed the variable names around a bit, formatted the code, added in the formulas, and added a 'q' choice to the menu to exit the program. I also added an 'if' statement to determine if the answers would be imaginary numbers, since I doubt you want to deal with those.

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	double a, b, c, x1, x2;
	char choice;
		do {
			cout << "						  Aaron's Algebra Fromula Calc!\n";
			cout << "\n";
			cout << "Pick A Formula...\n";
			cout << "1. QUDRATIC FORMULA!!!\n";
			cout << "2. Other\n";
			cout << "3. Other\n";
			cout << "Or press 'q' to quit." << endl;
			cin>>choice;
		} while ( choice < '1' || choice > '1' && choice != 'q');

		if (choice == 'q' || choice == 'Q') 
			return 0;

		switch (choice) 
		{
		case '1':
			cout << "Please input a\n";
			cin >> a;
			cout << "Please enter b\n";
			cin >> b;
			cout << "Please enter c\n";
			cin >> c;

			if(pow(b, 2) < 4 * a * c)
			{
				cout << "Imaginary numbers!" << endl;
				break;
			}

			x1 = (-b + sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
			x2 = (-b - sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);

			cout << "x1 = " << x1 << endl;
			cout << "x2 = " << x2 << endl;

			break;
		}
		return 0;
}	


Check here for info on the 'sqrt' and 'pow' functions from the <cmath> library.
http://www.dreaminco...wtopic34426.htm
Was This Post Helpful? 0
  • +
  • -

#6 AGRAC393  Icon User is offline

  • D.I.C Head
  • PipPip
  • Group: Members
  • Posts: 240
  • Joined: 13-May 09


Dream Kudos: 25

Posted 30 May 2009 - 06:03 AM

View Postapw5020, on 29 May, 2009 - 08:00 PM, said:

Nowhere do you actually use the quadratic formula that ABXG posted. Here is your code revised. I changed the variable names around a bit, formatted the code, added in the formulas, and added a 'q' choice to the menu to exit the program. I also added an 'if' statement to determine if the answers would be imaginary numbers, since I doubt you want to deal with those.

#include <iostream>
#include <cstdlib>
#include <cmath>

using namespace std;

int main()
{
	double a, b, c, x1, x2;
	char choice;
		do {
			cout << "						  Aaron's Algebra Fromula Calc!\n";
			cout << "\n";
			cout << "Pick A Formula...\n";
			cout << "1. QUDRATIC FORMULA!!!\n";
			cout << "2. Other\n";
			cout << "3. Other\n";
			cout << "Or press 'q' to quit." << endl;
			cin>>choice;
		} while ( choice < '1' || choice > '1' && choice != 'q');

		if (choice == 'q' || choice == 'Q') 
			return 0;

		switch (choice) 
		{
		case '1':
			cout << "Please input a\n";
			cin >> a;
			cout << "Please enter b\n";
			cin >> b;
			cout << "Please enter c\n";
			cin >> c;

			if(pow(b, 2) < 4 * a * c)
			{
				cout << "Imaginary numbers!" << endl;
				break;
			}

			x1 = (-b + sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);
			x2 = (-b - sqrt(pow(b, 2) - 4 * a * c)) / (2 * a);

			cout << "x1 = " << x1 << endl;
			cout << "x2 = " << x2 << endl;

			break;
		}
		return 0;
}	


Check here for info on the 'sqrt' and 'pow' functions from the <cmath> library.
http://www.dreaminco...wtopic34426.htm

Thanks APW! I know I can always count on you!

This post has been edited by AGRAC393: 30 May 2009 - 06:03 AM

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month