Hi,
My code so far works great. I would like to add in something for :
if a letter or character is entered for the price
The program would say invalid input and ask for the price again
And
If a number other than 1-3(locations), or a letter or character is entered
ask for location again
I don't know if it is even possible to do what I want. What I have so far is what we had to do for the assignment, I just wanted to add the rest in.
cpp
#include <stdio.h> // Includes standard input/output//
void main () //Tells us that there is no value when the program exits//
{
float Price = 0.00;
float DelMar = 7.25;
float Encinitas = 7.5;
float LaJolla = 7.75;
int Location;
printf (" Welcome to Kudler Tax Program\n\n");
printf(" Purchase Price is $125.00\n");
while (Price != 125.0) // Initiates the While loop for asking the user to input a Price and then if
{
printf("\n\nEnter Price: "); // Asking user to input price//
scanf("%f", &Price); //Reads in the purchase price and outputs it to the screen//
}
printf("\n\n"); // Allows for blank lines, in this case 2. Each N represents a line//
printf("1\tDel Mar\n"); // Tells user that Delmar choice is number one and that the city name is tabbed over from its location number//
printf("2\tEncinitas\n"); // Tells user that Encinitas choice is number Two and that the city name is tabbed over from its location number//
printf("3\tLa Jolla\n\n"); // Tells user that LaJolla choice is number Three and that the city name is tabbed over from its location number//
printf("Choose Location: "); // Asking user to choose a location for the tax amount//
scanf ("%d", &Location); //Reads the location and outputs it to the screen//
if( Location == 1)
printf ("\nDelMar 1: Tax = $%4.2f and Total Purchase = $%4.2f\n\n", (Price*(DelMar/100)), (Price+(Price*(DelMar/100))) ); //Compiles the purchase, calculates the tax and adds them for the total//
if (Location == 2)
printf ("\nEncinitas 2: Tax = $%4.2f and Total Purchase = $%4.2f\n\n", (Price*(Encinitas/100)), (Price+(Price*(Encinitas/100))) ); //Compiles the purchase, calculates the tax and adds them for the total//
if (Location == 3)
printf ("\nLaJolla 3: Tax = $%4.2f and Total Purchase = $%4.2f\n\n", (Price*(LaJolla/100)), (Price+(Price*(LaJolla/100))) ); //Compiles the purchase, calculates the tax and adds them for the total//
printf ("\nPress enter to close window and exit\n"); // Tells the compiler the user is done with the program//
getchar (); // Tells compiler to keep program open in order to close out of the program//
}// End//
** Edit **