I have tried %.02d and %02d to format the numerical data format but it keeps giving me 6 decimal places to the right. I have searched on the internet but I keep getting the same negative number. Please help. Here is what I have:
/*
*Standard C libraries
*/
#include <stdio.h>
#include <string.h>
/*
* Custom Headers
*/
/*
*Declarations
*/
char mealChoice[100];
double total = 0.0;
double subTotal = 0.0;
double mealCost = 0.0;
const double HST = 0.15;
const double ECO_DEPOSIT = 0.10;
//void calcTotal();
//void displayMenu(void);
//double getOrder();
int main(int argc, char *argv[])
{
printf("There is one size of hot/cold beverage: 435ml\n\n");
printf("Choices for hot beverages are: tea, cappachino, coffee\n\n");
printf("Choices for cold beverages are: orange juice, milk, chocolate milk, bottled water\n\n");
printf("Food choices for Breakfast: eggs, ham, bacon, toast with jam, and hasbrowns");
printf("Food choices for Lunch: Pizza, lasagna, mac n cheese with bacon\n\n");
printf("Food Choices for Dinner: Fish n' chips, sub with onion rings, fries, poutine, shephards pie, chicken alfredo \n\n");
printf("Prices for Breakfast: $12.50, Lunch: $15.00 and Dinner $35.00\n");
printf("Enter the customer's choice of Meal \n\n");
gets(mealChoice);
printf("Enter the cost of meal: \n");
scanf("%lf", &mealCost);
subTotal = mealCost + (mealCost * HST);
total = subTotal + ECO_DEPOSIT;
printf("\nYour order: %s", mealChoice, "\n");
printf("\nTotal cost: $ %lf", total, "\n");
printf("\nThank you for your support!\n");
printf("Come again! \n");
return 0;
}