Thank you for your responses! I used Narf's and it works fine now. I am just learning C, still getting used to using "(float)" properly and such.
Thought I would challenge myself to come up with a C program that accomplishes the same thing as: http://search.quiltshops.com/calculator/calculator.htm
(my wife suggested it when I asked for an idea, she uses the site)
Here is the entire working program if anyone is interested (I omitted the parts above that were uneeded to pose my question):
Code:
/* Quilting Fabric Calculator */
#include <stdio.h>
#include <stdlib.h>
int main()
{
int block_w, block_h, block_a, block_d, fabric, area, fab_a, light, medium, dark, run;
float yards, fab_d, light_f, medium_f, dark_f;
char choice;
do{
clrscr();
printf("Welcome to the Quilting Fabric Calculator\n");
printf("This program will tell you how much fabric\n");
printf("you will need to construct your quilt.\n");
printf("(press 1 to continue, 0 to exit): ");
scanf("%d", &run);
if(run == 1){
printf("\nEnter the width of each block (including seam allowance, in inches): ");
scanf("%d", &block_w);
printf("\nEnter the height of each block (including seam allowance, in inches): ");
scanf("%d", &block_h);
printf("\nEnter the number of blocks across quilt: ");
scanf("%d", &block_a);
printf("\nEnter the number of blocks down quilt: ");
scanf("%d", &block_d);
printf("\nEnter the fabric width (in inches): ");
scanf("%d", &fabric);
area = block_a * block_d;
fabric /= block_w;
fab_a = fabric;
fab_d = (float) area / fab_a;
yards = (float) (fab_d * block_h) / 36;
printf("\n\nYou will need %.2f yards of fabric for your quilt!", yards);
printf("\n\nWould you like me to calculate how much light/medium/dark fabric you will need (y/n)?");
scanf("%c", &choice);
if(choice == 'y'){
printf("\n\nPercent of quilt that will consist of light fabrics: ");
scanf("%d", &light);
printf("\nPercent of quilt that will consist of medium fabrics: ");
scanf("%d", &medium);
printf("\nPercent of quilt that will consist of dark fabrics (all should total 100): ");
scanf("%d", &dark);
light_f = yards * (light / 100.0f);
medium_f = yards * (medium / 100.0f);
dark_f = yards * (dark / 100.0f);
printf("\nYou will need %.2f yards of light, %.2f yards of medium, and %.2f yards of dark fabric for your quilt.\n\n",
light_f, medium_f, dark_f);
printf("\nPress Enter to continue...\n");
getchar();
}
}
}while(run == 1);
return 0;
}
Thanks again for your help!
Chris