Skip to content

Instantly share code, notes, and snippets.

@MuddyBootsCode
Last active June 28, 2016 07:47
Show Gist options
  • Save MuddyBootsCode/36dac6fc4fa43702af4223a85b6284fd to your computer and use it in GitHub Desktop.
Save MuddyBootsCode/36dac6fc4fa43702af4223a85b6284fd to your computer and use it in GitHub Desktop.
#include<stdio.h>
void townCountry();
void gasCalc();
void gasPrice();
char live;
float cityReg = 1.254;
float cityHO = 1.309;
float citySO = 1.399;
float subReg = 1.139;
float subHO = 1.179;
float subSO = 1.279;
float regular, highOctane, superOctane;
int main()
{
printf("Please enter your location (City/Suburb):\n");
scanf("%c", &live);
townCountry();
gasCalc();
gasPrice();
return (0);
}
void townCountry()
{
if (live == 'c' || live == 'C')
live = 'c';
else if (live == 's' || live == 'S')
live = 's';
}
void gasCalc()
{
if (live == 'c')
{
regular = (cityReg * 15);
highOctane = (cityHO * 15);
superOctane = (citySO * 15);
}
else
{
regular = (subReg * 15);
highOctane = (subHO * 15);
superOctane = (subSO * 15);
}
}
void gasPrice()
{
printf("The average prices for a fill up are:\n");
printf("\n");
printf("regular\tHigh Octane\tSuper Octane");
printf("%.2f\t%.2f\t%.2f\t", regular, highOctane, superOctane);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment