[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

I am looking for advice on my project..

Asked by jasmith71 in C Programming Language

Tags: C, IE 7.0, Advice

I am submitting my assignment for review by pro's to see if you think this code is clean and follows standard programming. The criteria of my assignment are met with my code, but I know someone would have a good suggestion for cleaning it up a bit.

Assignment:
Prompt for clerck to enter current prices for products.

Then display those product prices back.

Use a customer checkout function to prompt the customer for how much of each
item he or she would like to purchase.

If the total is more than $50, a 5% discount is applied.

Prompt user to enter the amount of money the customer has to spend.

Compare that with the total of the purchase and display change or amount due.

My Code
#include<time.h>
#include <stdio.h>


int main(void)    //Beginning of program
{

    time_t timer;
    float flbGrapes1;
    float flbPears2;
    float flbBellpeppers3;
    float flbNectarines4;
    float flbPotatoes5;
    float fMoney;
    float fMoney2;
    float ftotLbs1;
    float ftotLbs2;
    float ftotLbs3;
    float ftotLbs4;
    float ftotLbs5;
    float fTotGrapes1;
    float fTotPears2;
    float fTotBellpeppers3;
    float fTotNectarines4;
    float fTotPotatoes5;
    float ftotPurch;
    float fdisc;
    float ftotDollar;
   
    //initialize variables
    flbGrapes1 = 0.00;
    flbPears2 = 0.00;
    flbBellpeppers3 = 0.00;
    flbNectarines4 = 0.00;
    flbPotatoes5 = 0.00;
     
    fMoney = 0.00;
    fMoney2 = 0.00;
    ftotLbs1 = 0.00;
    ftotLbs2 = 0.00;
    ftotLbs3 = 0.00;
    ftotLbs4 = 0.00;
    ftotLbs5 = 0.00;
    timer=time(NULL);
    ftotDollar = (flbGrapes1 * ftotLbs1) + (flbPears2 * ftotLbs2) + (flbBellpeppers3 * ftotLbs3) + (flbNectarines4 * ftotLbs4) + (flbPotatoes5 * ftotLbs5);
    fdisc = (ftotPurch * .05);
   

//Greeting and time    
printf("Welcome to Reggie's Friendly Neighborhood Grocery Store!\n");
printf("\n");
printf("The current time is %s\n",asctime(localtime(&timer)));
printf("\n");
printf("\n");

//Prompt user to enter price per pound
printf("Please enter the price per pound for your Grapes: $");
scanf("%f", &flbGrapes1);
printf("\n");
printf("Please enter the price per pound for your Pears: $");
scanf("%f", &flbPears2);
printf("\n");
printf("Please enter the price per pound for your Bell peppers: $");
scanf("%f", &flbBellpeppers3);
printf("\n");
printf("Please enter the price per pound for your Nectarines: $");
scanf("%f", &flbNectarines4);
printf("\n");
printf("Please enter the price per pound for your Potatoes: $");
scanf("%f", &flbPotatoes5);
printf("\n");
printf("\n");

//Display price per pound entered
printf("You have entered the following:\n");
printf("\n");
printf("$%.2f a pound for grapes.\n", flbGrapes1);
printf("\n");
printf("$%.2f a pound for pears.\n", flbPears2);
printf("\n");
printf("$%.2f a pound for bell peppers.\n", flbBellpeppers3);
printf("\n");
printf("$%.2f a pound for nectarines.\n", flbNectarines4);
printf("\n");
printf("$%.2f a pound for potatoes.\n", flbPotatoes5);
printf("\n");
printf("\n");

//Ask for the total pounds
printf("How many pounds of grapes would you like to purchase?\n", ftotLbs1);
printf("\n");
scanf("%f", &ftotLbs1);
printf("\n");
printf("The total amount for the grapes is $%.2f: \n", flbGrapes1 * ftotLbs1);
printf("\n");
printf("\n");

printf("How many pounds of pears would you like to purchase?\n", ftotLbs2);
printf("\n");
scanf("%f", &ftotLbs2);
printf("\n");
printf("The total amount for the pears is $%.2f: \n", flbPears2 * ftotLbs2);
printf("\n");
printf("\n");

printf("How many pounds of bell peppers would you like to purchase?\n", ftotLbs3);
printf("\n");
scanf("%f", &ftotLbs3);
printf("\n");
printf("The total amount for the bell peppers is $%.2f: \n", flbBellpeppers3 * ftotLbs3);
printf("\n");
printf("\n");

printf("How many pounds of nectarines would you like to purchase?\n", flbNectarines4 * ftotLbs4);
printf("\n");
scanf("%f", &ftotLbs4);
printf("\n");
printf("The total amount for the nectarines is $%.2f: \n", flbNectarines4 * ftotLbs4);
printf("\n");
printf("\n");

printf("How many pounds of potatoes would you like to purchase?\n", flbPotatoes5 * ftotLbs5);
printf("\n");
scanf("%f", &ftotLbs5);
printf("\n");
printf("The total amount for the potatoes is $%.2f: \n", flbPotatoes5 * ftotLbs5);
printf("\n");
printf("\n");

ftotDollar = (flbGrapes1 * ftotLbs1) + (flbPears2 * ftotLbs2) + (flbBellpeppers3 * ftotLbs3) + (flbNectarines4 * ftotLbs4) + (flbPotatoes5 * ftotLbs5);
     
//Total dollar amount of all products entered
printf("The total of these products is $%.2f \n", ftotDollar);
printf("\n");


fdisc = (ftotDollar * .05);
ftotPurch = (ftotDollar - fdisc);
ftotDollar = (flbGrapes1 * ftotLbs1) + (flbPears2 * ftotLbs2) + (flbBellpeppers3 * ftotLbs3) + (flbNectarines4 * ftotLbs4) + (flbPotatoes5 * ftotLbs5);

//If total amount is over $50    
{
if (ftotDollar > 50.00)
 printf("You will receive a 5 percent discount, which totals: $%.2f \n", fdisc);
 printf("\n");
if (ftotDollar > 50.00)
 printf("The total amount of your purchase is $%.2f \n", ftotPurch);
 printf("\n");

}
printf("Enter the amount of money that you will be spending: $");
scanf("%f", &fMoney);
printf("\n");
printf("\n");

{
if (fMoney < ftotDollar)
 printf("Amount entered is not enough for purchase, please input a larger amount: $");
 scanf("%f", &fMoney);
 printf("\n");
if (fMoney > ftotDollar)
 printf("Your change is $%.2f \n", fMoney-ftotDollar);
 else
 printf("Your change is $%.2f \n", fMoney-ftotPurch);
 printf("\n");
 printf("Thank you for shopping at Reggie's! Have a good day and please visit us again!");
}

{
if (fMoney < ftotPurch)
 printf("Amount entered is not enough for purchase, please input a larger amount: $");
 scanf("%f", &fMoney);
 printf("\n");
if (fMoney > ftotPurch)
 printf("Your change is $%.2f \n", fMoney-ftotPurch);
 printf("\n");
}


 printf("Thank you for shopping at Reggie's! Have a good day and please visit us again!");
 getchar();
return 0;
}


[+][-]03/17/08 11:26 AM, ID: 21144752Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: C Programming Language
Tags: C, IE 7.0, Advice
Sign Up Now!
Solution Provided By: itsmeandnobodyelse
Participating Experts: 4
Solution Grade: A
 
[+][-]03/17/08 10:09 AM, ID: 21144106Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/17/08 11:29 AM, ID: 21144776Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]03/17/08 05:48 PM, ID: 21147653Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 / EE_QW_2_20070628