Hello I'm doing an app purchasing program and my setcost function will only print the the cost of one the apps for whatever I input. My program is not finished yet, so not all my function definitions have been defined. Thank you for your help.
Code:
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <ctype.h>
// Displays the list of apps available
//prompts for the user’s selection and sets the value of the selection
void DisplayApps(char *selectionPtr);
//sets the cost of the item based on value stored in purchase
void SetCost(char selection, double *costPtr);
//Displays the codes for the user to input money - gets user input amounts
//compares the int codes and updates the deposit amount
void PaymentOptions(double *depositPtr, double cost);
//compares the amount the user has in deposits to the price of app selected.
//It returns 1 if the amount is enough to cover the cost, 0 if there is not enough.
int Compare(double deposit, double choiceCost);
//uses PaymentOptions function to display and collect dollar amounts from the user
//uses Compare function to keep comparing the added deposited amount to the item cost.
void Pay(double *depositPtr, double choiceCost);
//calculates the amount of leftover from your deposits
void GetChange(double *depositPtr, double choiceCost);
//Asks the user if they want another app
void DoItAgain(char *quitPtr);
int main()
{
char again, selection;
double cost;
printf("Welcome To The App Store\n");
printf("***********************************\n");
do {
// Amount of money
//Display the Apps
DisplayApps(&selection);
SetCost(selection, &cost);
printf("cost is %.2lf\n", cost);
DoItAgain(&again);
} while (again == 'Y');
return 0;
}
void DoItAgain(char *quitPtr)
{
printf("Do you want to make another purchase?\n");
scanf(" %c", quitPtr);
*quitPtr = toupper(*quitPtr);
}
void DisplayApps(char *selectionPtr)
{
printf("Here are your selections:\n\n");
printf("C -- Clown Punching $299.99\n");
printf("V -- Virtual Snow Globe $249.99\n");
printf("R -- Remote PC $999.99\n");
printf("G -- Grocery List Helper $2.99\n");
printf("M -- Mobile Cam Viewer $89.99\n\n\n");
printf("Please enter a selection\n");
scanf(" %c", selectionPtr);
*selectionPtr = toupper(*selectionPtr);
printf("Your selection was: %c\n", *selectionPtr);
printf("-------------------------------------------------\n");
}
void SetCost(char selection, double *costPtr)
{
if (selection = 'C')
{
*costPtr = 299.99;
}
else if (selection = 'V')
{
*costPtr = 249.99;
}
else if (selection = 'R')
{
*costPtr = 999.99;
}
else if (selection = 'G')
{
*costPtr = 2.99;
}
else if (selection = 'M')
{
*costPtr = 89.99;
}
}