The last funtion IsPrimeNumber () is giving me an error that states ..."Local Function definitions are illegal"....can someone please tell me why? Thanks
/******************************************************************
Name :
Date :
Homework # : Homework #6 Problem #1
Source :
Action : Menu is displayed allows user to calculate
Miles per Gallon, Total minutes and seconds
and determine if number is a prime number or not
Notes :
********************************************************************/
#include <iostream>
#include <stdlib.h> // this header file requires the .h
using namespace std;
void DisplayMenu(void);
void FindMilesPerGallon(void);
void ConvertTotalSeconds(void);
void IsPrimeNumber(void);
void main()
{
int Choice;
system("cls"); // this clears the output screen
DisplayMenu();
cin >> Choice;
while (Choice != 4)
{
switch (Choice)
{
case 1: FindMilesPerGallon();
break;
case 2: ConvertTotalSeconds();
break;
case 3: IsPrimeNumber();
break;
default : cout << "Sorry illegal choice, Please try again\n\n";
}
DisplayMenu();
cin >> Choice;
}
}
/********************* DisplayMenu ************************************
Action : This just displays the menu to the screen
Parameters : none
returns : nothing
***********************************************************************/
void DisplayMenu()
{
cout << "\n\nDo you want to:\n";
cout << " 1) Find miles per gallon\n";
cout << " 2) Convert total seconds to minutes and seconds\n";
cout << " 3) Determine if number is a prime number or not\n";
cout << " 4) QUIT\n\n";
cout << " CHOICE --> ";
}
/******************** FindMilesPerGallon ******************************
Action : Ask user to input number of miles traveled and number of
gallons used then display the miles per gallon obtained.
Parameters : none
returns : nothing
------------------------------------------------------------------------*/
void FindMilesPerGallon(void)
{
float Miles = 0, Gallons = 0, MPG;
cout << "Please enter the number of gallons used--> ";
cin >> Gallons;
cout << endl << endl;
cout << "Please enter miles traveled--> ";
cin >> Miles;
cout << endl << endl;
MPG = Miles / Gallons;
cout << "Your MPG is--> " << MPG << endl << endl;
}
/******************** ConvertTotalSeconds *********************
Action : Ask user to input a given total number of seconds and then
displays the corresponding number of minutes and seconds
Parameters : none
returns : nothing
-------------------------------------------------------------------------*/
void ConvertTotalSeconds (void)
{
int Seconds, Minutes, TotalSeconds = 0;
cout << "Please enter total seconds to convert--> ";
cin >> TotalSeconds;
cout << endl << endl;
Minutes = TotalSeconds / 60;
Seconds = TotalSeconds % 60;
cout << "There are " << Minutes << " minutes and " << Seconds << " seconds.";
cout << endl << endl;
/*********************** IsPrimeNumber()****************************
Action : Ask user to input positive integer and will determine if number
is a prime number or not.
Parameters : none
Returns : nothing
-------------------------------------------------------------------*/
void IsPrimeNumber (void)
{
int Num;
cout << "Please enter number to check if it's prime--> ";
cin >> Num;
cout << endl << endl;
if (Num % Num == 0)
{
cout << "Your number is prime.\n\n";
}
else
{
cout << "Your number is not prime.\n\n";
}
}