don't think this makes much sense but this is what i have so far:
Code:
#include <stdio.h>
#define COST 40
#define ROWS 10
#define COLS 10
int menu(void);
void dispDistance(void);
void journeyCost(void);
void dispChart(void);
int array[ROWS][COLS]; //is this a global variable declaration?
int main(void)
{
int choice;
while(choice !='q')
{
switch()
{
case '1':/*display distance*/
dispDistance();
break;
case '2':/*calculate cost of journey*/
journeyCost();
break;
case '3':/*display the chart*/
dispChart();
break;
default:
puts("Please enter a valid number");
}/*end switch*/
}/*end while*/
return 0;
}
int menu(void)
{
int menuChoice;
puts("Menu");
Puts("1) Display distance between two places");
Puts("2) Calculate the cost of a journey");
Puts("3) Display the full mileage chart");
Puts("q) Quit\n");
scanf("%d",&menuChoice);
return choice;
}
void dispDistance()
{
int x,y;
printf("Enter starting point: ");
scanf("%d",&x);
printf("Enter end point: ");
scanf("%d",&y);
if(x>ROWS-1 || x<COLS+1 || y>ROWS-1 || y<COLS+1)
{
printf("The distance between point x and point y is: %d \n", array[x-1][y-1]);
return array[x-1][y-1];
}
else
{
printf("Invalid entry\n");
}/*end if*/
return 0;
}/*end display distance*/
void journeyCost()
{
float cost;
cost = dist * 0.4;
printf("Cost of the journey is: %f\n", cost);
}/*end journey cost*/
void dispChart()
{
int x,y;
for(x=0;x<ROWS;x++)
{
printf("\n");
for(y=0;y<COLS;y++)
{
printf("\t%d", array[x][y]);
}/*end for*/
}/*end for*/
}/*end dispay chart*/
any help would be much appreciated.
Thanks