For starters this program is far from finished, I just completed the first option of my menu and I wanted to test it out but when I compile it, all the way at the very end with the last } I get an error saying "Expected declaration or statement at end of input". I've tried fooling around with more brackets, returning 0, and a bunch of other stuff but I can't figure out why it won't let me compile it. Also I'm just learning functions and still pretty bad with them so don't be surprised if there's all kinds of other crazy stuff wrong :P
Code:
#include <stdio.h>
#define PI 3.14159
#define INCHES_IN_MILE 63360
void printmenu();
void tripfueleff();
void printrating ();
void getitem();
void printlogo();
void printfuelgraph();
int main(){
int ans;
//Get user's input
menu();
scanf("%d", &ans);
while (ans !=6) {
if (ans==1) {
tripfueleff();
}
//Prints out menu
void menu() {
printf("Which of the following options would you like?\n");
printf("1) Calculate fuel efficiency for a trip.\n");
printf("2) Determine whether or not to go back home and pick up an item.\n");
printf("3) Print the car logo to the display.\n");
printf("4) Play the multiplication game.\n");
printf("5) Print a visual display of the recent fuel efficiency.\n");
printf("6) Quit\n");
}
//Calculates fuel efficiency
void tripfueleff() {
int revs, totalrevs, rad, pass=1, time, time1=0, time2=5, interval1, interval2, finalmpg;
double gas, totalgas, mpg, dist, totaldist;
//User Input
printf("How long was your trip in minutes?\n");
scanf("%d", &time);
printf("What is the radius of your tires, in inches?\n");
scanf("%d", &rad);
//Determine 5 minute intervals
interval1 = (time / 5);
interval2 = (time / 5);
while (interval1 > 0) {
printf("During time interval #%d, how many revolutions did your car's tires make?\n", pass);
scanf("%d", &revs);
totalrevs = totalrevs + revs;
printf("During time interval #%d,how many gallons of gas did your car use?\n", pass);
scanf("%lf", &gas);
totalgas = totalgas + gas;
pass++;
//Calculate mpg
dist = ((rad*2*PI)*(revs)) / INCHES_IN_MILE;
mpg = dist/gas;
time1 = time1 + 5;
time2 = time2 + 5;
printf("Time %d-%d minutes: Your car averaged %.2lf miles per gallon\n", time1, time2, mpg);
interval1--;
}
totaldist = ((rad*2*PI)*(totalrevs)) / INCHES_IN_MILE;
finalmpg = totaldist / totalgas;
printf("For the whole trip, your car averaged %d mpg.\n", finalmpg);
}