You work for a major grocer and corporate is starting a majo

You work for a major grocer, and corporate is starting a major initiative with regards to automatic checkouts. They have developed a new prototype for a cart with a credit card reader, where the customer swipes their card before entering the store. The cart then tracks all of the items which the customer places in it, and adds to that customer\'s total. Upon exiting the store, the cart automatically charges the customer\'s card for the appropriate amount. In general, this technology works with RFID that has already been in packaging for years. However, there is a yet unsolved aspect regarding food which cannot have RFID, namely produce. You are developing expiremental software to solve the produce problem. Your software will run on special carts in select stores. Unlike the main technology, the customers will be unaware of your software\'s execution. Your software\'s goal is to estimate the value of the produce which the customer has in their cart, which will then be compared to the true value of the produce at checkout time. When the customer places a piece of produce into their cart, two things are known: a. Price/Pound (communicated through RFID from a nearby bin) b. Item Weight These two statistics can be used to report the total price. Your software must be able to handle the case where a user removes something from a cart. When this is done, only the weight of the item is known. a. Go through each placement, and search for the one with the closest weight (sometimes the weight upon removal is slightly different than placement due to measurement errors.) b. If two or more placements are found with the same weight differential, the one with the lowest Price/Pound is kept, i.e., not removed (better to rule in the customer\'s favor). There will be several distinct features which your program may perform, each worth varying degrees of points. As you may recall, each project is worth 10% of your final grade. The project will be graded out of 100 points, or in other words, a score of 100/100 will be considered full marks. 110 is the maximum possible score. There are more than 110 points available in the project, but no grade will be assigned higher than 110/100. Students are encouraged to do all of the parts, in case they make an error in some. Failing to follow these rules will result in a deduction of up to 40% of the final grade. That is, if you make a 80/100, failing to follow these rules may result in up to 32 points being deducted (40% of 80). Submit a single file, named Produce Cart .c. Upon starting, and immediately following any complete action, the program displays a menu, described as follows: Program prints \"Make a selection: (a)dd, (r)emove, (t)otal, or (q)uit. \" (note the space and lack of newline). a. After the user makes a selection, the next text varies. If the user selects (a): i. The program prints \"Enter a Price/Pound: \". The user must enter the price per pound as a float. ii. The program prints \"Enter a Weight: \". The user must enter the weight as a float. iii. The program prints a single newline character and returs to the beginning of the menu. b. If the user selects (r): i. The program prints \"Enter a Weight: \". The user must enter the weight as a float. ii. The program prints a single newline character and returs to the beginning of the menu. c. If the user selects (t): i. The program prints \"The current total is: $X.\", where X is replaced by the current total as a float with exactly two digits after the decimal place. Truncate any extra digits rather than rounding. ii. The program prints a single newline character and returs to the beginning of the menu. d. If the user selects (q), the program quits immediately.

Solution

The below program implements the logic of adding a product, showing total, and exiting the program perfectly fine. I have also implemented the logic to remove a product but you need to look into it to make it work perfectly work fine.

#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;
    int j,userItem;
    static float minPrice,totalPrice = 0;
    do{
        int flag=0;
        static int i = 0;
        float pricePerPound,netWeight,userWeight, weightDiff = 0, itemWeightArray[100],itemPriceArray[100];
        while (flag == 0)
        {
            printf(\"\ Make a selection: (a)dd, (r)emove, (t)otal or (q)uit.\");
            scanf(\"%c\",&ch);
            if(ch==\'a\' || ch==\'r\' || ch==\'t\' || ch==\'q\')
            flag = 1;
            if(flag == 0)
            printf(\"\ \ Wrong input!\ \");
        };
        switch(ch){
            case \'a\':
                printf(\"\ Enter a price/pound: \");
                scanf(\"%f\",&pricePerPound);
                printf(\"\ Enter a weight: \");
                scanf(\"%f\",&itemWeightArray[i]);
                itemPriceArray[i] = itemWeightArray[i] * pricePerPound;
                totalPrice += itemPriceArray[i];
                i++;
                printf(\"\ \");
                break;
            case \'r\':
                printf(\"\ Enter a weight: \");
                scanf(\"%f\",&userWeight);
                for(j=0;j<100;j++){
                    if(j==0 || abs(userWeight - itemWeightArray[j]) < weightDiff){
                        weightDiff = abs(userWeight - itemWeightArray[j]);
                        userItem = j;
                    }
                }
                for(j=0;j<100;j++){
                    if(abs(userWeight - itemWeightArray[j])==weightDiff){
                        if(j==0 || minPrice < itemPriceArray[j]){
                            minPrice = itemPriceArray[j];
                        }
                    }
                }
                totalPrice -= minPrice;
                printf(\"\ \");
                break;
            case \'t\':
                printf(\"\ The current Total is: %f\",totalPrice);
                break;
            case \'q\':
                break;
        }
    }
    while(ch != \'q\');
    return 0;
}

 You work for a major grocer, and corporate is starting a major initiative with regards to automatic checkouts. They have developed a new prototype for a cart w
 You work for a major grocer, and corporate is starting a major initiative with regards to automatic checkouts. They have developed a new prototype for a cart w

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site