I'm having a similar problem with the same program. Strange that we have the exact same homework. You wouldn't be chance be attending ucf would you?
Anyway here is what my code looks like.
Code:
#include <stdio.h>
int main( )
{
/* I used the int function to define totalfishsale because we cant have a fraction or
.xx of a fish.*/
int totalfishsale;
/* First I defined the variables via the double function length, width and height as l, w, and h.
I also defined priceperinch, maintenance, profit, fishprice, and cost here. */
double l, w, h, cost, priceperinch = 0.02, maintenance = 0.005, profit, fishprice = 5.00;
/* The first print and scan functions prompt the user for the length of the fish tank in inches*/
printf("What is the length of your fish tank in inches?\n");
scanf("%lf", &l);
/* The second print and scan functions prompt the user for the width of the fish tank in inches */
printf("What is the width of your fish tank in inches?\n");
scanf("%lf", &w);
/* The third print and scan functions prompt the user for the height of the fish tank in inches */
printf("What is the height of your fish tank in inches?\n");
scanf("%lf", &h);
/* This Equation calculates the cost of maintenance and construction of the fish tank */
cost = ( ( (l * w) + (h * l * 2) + (w * h * 2) ) * priceperinch ) + ( ( l * w * h ) * maintenance );
/* This equation calculates the total profit for the amount of fish sold at the fishprice */
totalfishsale = ( ( l * w * h )/250.0 ) * fishprice;
/* This equation subtracts the cost of production from the total profit for the amount of fish sold */
profit = totalfishsale - cost;
if ( profit < 0.0 )
{
printf("\n Your loss from selling fish is $%.2f\n", profit);
}
else if ( profit > 0.0 )
{
printf("\n Your profit from sellling fish is $%.2f\n", profit);
}
else
{
printf("\n You break even from selling fish.\n");
}
}
Now when i input the variable 6, 6, and 6 instead of getting 4.68 I'm gettting -0.68. I've looked it over a number of times and compared my code to bronson's but i can't seem to figure out what's wrong. I'm thinking maybe it's a format issue or something? I don't know I'm still really new to the whole coding business since I've only ever done html before.
-matt