3 Replies - 1244 Views - Last Post: 17 October 2013 - 06:44 AM Rate Topic: -----

#1 gyneisler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 19-May 13

Can not get this math menu porgram to work.

Posted 16 October 2013 - 09:59 AM

I can not get this math menu driven program to work. also, how do you go about setting up a prime function program for this program. Have been trying for five days now.




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

using namespace std;

void showChoices();
double prime(double, double);
double abs(double, double);
double pow(double, double);
double hypont(double, double);

int main()
{
	double x, y;
	int choice;
	do
	{
		showChoices();
		cin >> choice;
		switch (choice)
		{
		case 1:
			cout << "Enter one number: ";
			cin >> x ;
			cout << "prime numbers " << prime(x,y) <<endl;
			break;
		case 2:
			cout << "Enter one number: ";
			cin >>x ;
			cout << "The Absolute value is: " << abs(x) <<endl;
			break;
		case 3:
			cout << "Enter two numbers: ";
			cin >> x >> y;
			cout << "power " << pow(x,y) <<endl;
			break;
		case 4:
			cout << "Enter two numbers: ";
			cin >> x >> y;
			cout << "Hyptenuse " << hypont(x,y) <<endl;
			break;
		case 5:
			break;
		default:
			cout << "Invalid input" << endl;
		}
	}while (choice != 5);

	return 0;
}

void showChoices()
{
	cout << "MENU" << endl;
	cout << "1: Prime " << endl;
	cout << "2: Absolute value of a number" << endl;
	cout << "3: Compte X raised to the Y power " << endl;
	cout << "4: Hypotenuse Value " << endl;
	cout << "5: Quit the math program " << endl;
	cout << "Please enter a number (1-5):";
}

double prime(double a, double B)/>/>
{
	return a;
}

double abs(double a)
{
	return a;
}

double pow(double a, double B)/>/>
{

	return a;
   
}

double hypont(double a, double B)/>/>
{
	return a;
}


Is This A Good Question/Topic? 0
  • +

Replies To: Can not get this math menu porgram to work.

#2 no2pencil  Icon User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6544
  • View blog
  • Posts: 30,651
  • Joined: 10-May 07

Re: Can not get this math menu porgram to work.

Posted 16 October 2013 - 10:03 AM

What isn't working? The code you provided compiles, & the menu functions for me.

Quote

make junk
g++ junk.cpp -o junk
./junk
MENU
1: Prime
2: Absolute value of a number
3: Compte X raised to the Y power
4: Hypotenuse Value
5: Quit the math program
Please enter a number (1-5):1
Enter one number: 4
prime numbers 4

Was This Post Helpful? 0
  • +
  • -

#3 jimblumberg  Icon User is offline

  • member icon

Reputation: 5303
  • View blog
  • Posts: 16,520
  • Joined: 25-December 09

Re: Can not get this math menu porgram to work.

Posted 16 October 2013 - 10:19 AM

Why are you redefining the standard C functions pow() and abs()? You need to rename these functions or just use the standard functions.

Also we will not write the "prime" function for you. You need to show what you've tried and ask specific questions.

Just throwing a bunch of "stub" functions at us doesn't show much actual work, you need to do much better or I'll close the topic.


Jim
Was This Post Helpful? 0
  • +
  • -

#4 gyneisler  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 19-May 13

Re: Can not get this math menu porgram to work.

Posted 17 October 2013 - 06:44 AM

I am new to C++ programming and I did not know my code was loaded with stabs until I read my textbook again. However, I was able to fix the problems.

This post has been edited by gyneisler: 17 October 2013 - 06:45 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1