Hi all
I'm extremely new to coding. I have been working on this piece for a school assignment for a couple days now and I am stuck. Basically it is to come up with tax amounts and total sales for a fictional company. It compiles fine, but it doesn't seem to want to return valid input. No matter what amount I enter in as input, I always get "invalid input" returned. I can't figure out why because it looks right to me. Can someone point me in the right direction please?
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
// Declare variables
float sales = 0.0;
float trateDelmar = .0725;
float trateEncinitas = .0750;
float trateLajolla = .0775;
float staxDelmar = 0.0;
float totamtDelmar = 0.0;
float staxEncinitas = 0.0;
float totamtEncinitas = 0.0;
float staxLajolla = 0.0;
float totamtLajolla = 0.0;
char input[10];
// Program header
printf("\nTax calculation program for Kudler stores\n");
printf("\nEnter Purchase Amount: ");
// Read the input and assign it to sales
scanf("%s", input);
sales = atof(input);
if(sales <= 0.0);
{
printf("Invalid input \n");
return 1;
}
// Calculating the sales tax and total amount
staxDelmar = trateDelmar * sales;
totamtDelmar = staxDelmar + sales;
staxEncinitas = trateEncinitas * sales;
totamtEncinitas = staxEncinitas + sales;
staxLajolla = trateLajolla * sales;
totamtLajolla - staxLajolla + sales;
// Displaying the tax rate, sales tax and total amount
printf("\n \tTax\tSales\tTotal\n");
printf("District\tRate\tTax\tSale Amount\n");
printf("------------------------------\n");
printf("Del Mar \t%4.2f\t%4.2f\t%4.2f\n", trateDelmar, staxDelmar, totamtDelmar);
printf("Encinitas \t%4.2f\t%4.2f\t%4.2f\n", trateEncinitas, staxEncinitas, totamtEncinitas);
printf("LaJolla \t%4.2f\t%4.2f\t%4.2f\n", trateLajolla, staxLajolla, totamtLajolla);
return 0;
}
// End of program
I just don't understand why this isn't working. If someone can see why, an explanation would be great. I am having a hard time understanding why this doesn't work correctly.
Thanks!