# Can not get this math menu porgram to work.

Page 1 of 1

## 3 Replies - 1348 Views - Last Post: 17 October 2013 - 06:44 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=331693&amp;s=0c7c03634810bed252f6c88692b1a79a&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 gyneisler

Reputation: 0
• 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 << "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

• Professor Snuggly Pants

Reputation: 6659
• Posts: 30,977
• 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
1: Prime
2: Absolute value of a number
3: Compte X raised to the Y power
4: Hypotenuse Value
5: Quit the math program
Enter one number: 4
prime numbers 4

### #3 jimblumberg

Reputation: 5537
• Posts: 17,144
• 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

### #4 gyneisler

Reputation: 0
• 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