Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,185 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,380 people online right now. Registration is fast and FREE... Join Now!




C Program - Kudler Fine Foods CR#1

 
Reply to this topicStart new topic

C Program - Kudler Fine Foods CR#1, Calc the correct tax type for multiple locations

MustangAlice
31 May, 2008 - 10:24 PM
Post #1

New D.I.C Head
*

Joined: 10 May, 2008
Posts: 5

Please point me in the right direction I've been working on this for 3 days. I'm so frustrated I just need a little direction...please

I'm attempting to modify the C program so that the user inputs the purchase amount. Check the user’s input for validity. In addition to calculating the sales tax for each location,calculate and display the total
sale amount for each location.
Tax Calculations: Del Mar=7.25%,Encinitas=7.50%, La Jolla= 7.75%
/***********************************************************
SR-kf-008, Change Request#1
Kudler Fine Foods

Tax Calculations: Del Mar=7.25%,Encinitas=7.50%, La Jolla= 7.75%
*************************************************************/

#include <stdio.h> // Include standard I/O libraries
#include <stdlib.h> // Include standard libraries
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: C Program - Kudler Fine Foods CR#1
31 May, 2008 - 10:33 PM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,504



Thanked: 67 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
QUOTE(MustangAlice @ 1 Jun, 2008 - 02:24 AM) *

I'm attempting to modify the C program so that the user inputs the purchase amount.

Where are you getting the input?

From the command line (fed into the program)?
Prompt the user & then listen for input?
Read it from a file?
User is offlineProfile CardPM
+Quote Post

MustangAlice
RE: C Program - Kudler Fine Foods CR#1
31 May, 2008 - 10:46 PM
Post #3

New D.I.C Head
*

Joined: 10 May, 2008
Posts: 5

I'm in luck one of the students posted their response. I'll look through their code to see if it can help me create my own. Thx!

/*-----------------------------------------------------------------------------
Program:
Date:
Author:
Class:
Requestor:
Change: Change Request #1

Description: This C program will prompt the user to enter the purchase amount
and will check the user's input for validity. The correct tax
amount and total purchase amount will be calculated on the input
value. The purchase amount, Tax amount, and Total Sale amount
will be displayed for each store location at Kudler Fine Foods.

Tax Rates: Del Mar (7.25%), Encinitas (7.5%), La Jolla (7.75%)
-------------------------------------------------------------------------------*/
#include <stdio.h> // Include standard I/O libraries
#include <stdlib.h> // Include standard libraries
#include <math.h> // Include Math libraries

#define DMTaxRate 7.25 /* Set constant Tax Rate for Del Mar = 7.25% */
#define ENTaxRate 7.50 /* Set constant Tax Rate for Encinitas = 7.50% */
#define LJTaxRate 7.75 /* Set constant Tax Rate for La Jolla = 7.75% */


main()
{
char Purchase[32]; /* Declare program variables */
double Amount,DMTax,ENTax,LJTax;
int i,NV=0;

/* Prompt user for Purchase Amount */
printf("\n\n\tKudler Fine Foods Tax Calculator\n\n");
printf("\n\n\tPlease Enter Amount of Purchase:");
printf("\n\n\t===> ");
scanf("%s", Purchase);

/* Loop - Test each character in Input String (Purchase) */
for(i=0; Purchase[i]; i++)
{
if(Purchase[i] < '0' || Purchase[i] > '9') /* Test for a numeric value (0-9) */
{
if (Purchase[i] == '.') /* If character is a decimal continue */
continue;
else
NV=1; /* Set Non-Numerical Value flag */
break;
}
}

if (NV == 1) /* If Non-Numerical Value print Error Message */
{
printf("\n\n\n\tError! Invalid Purchase Amount [ %s ]\n",Purchase);
fflush(stdin);
printf("\n\n\n\tPress any key to continue...\n\t");
getchar(); /* Pause to allow viewing of output on screen */
return 0;
}


Amount=atof(Purchase); /* Convert Ascii character to Float */
DMTax=(Amount*DMTaxRate)/100; /* Calculate Tax Amount for Del Mar */
ENTax=(Amount*ENTaxRate)/100; /* Calculate Tax Amount for Encinitas */
LJTax=(Amount*LJTaxRate)/100; /* Calculate Tax Amount for La Jolla */

/* Display Tax Calculation output to the screen */
printf("\n\n\tKudler Fine Foods Tax Calculations by Store:\n\n");
printf("\n\tDel Mar Tax on $%.2f = $%4.2f Total = $%4.2f",Amount,DMTax,Amount+DMTax);
printf("\n\tEncinitas Tax on $%.2f = $%4.2f Total = $%4.2f",Amount,ENTax,Amount+ENTax);
printf("\n\tLa Jolla Tax on $%.2f = $%4.2f Total = $%4.2f",Amount,LJTax,Amount+LJTax);

fflush(stdin);
printf("\n\n\n\tPress any key to continue...\n\t");
getchar(); /* Pause to allow viewing of output on screen */
return 0;
}

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/4/08 11:30AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month