PLEASE HELP ASAP!! I have only been learning C for about a month so I am not as familiar with the terms and concepts as I would like to be. I know that there are actually more issues than I have mentioned; particularly with my assignment operators. I know I need to have some variables with asterisks in my function prototypes and calls but I am not sure when, where and why to use the asterisk and ampersand in functions.
This program is supposed to help a bookstore estimate its business.
I am required to: 1. Use a defined constant for the rate of profit.
2. Input should not be case-sensitive, so I have used a tolower() function. If the input is erroneous I am supposed to use an exit() function, which I am not sure I have done correctly.
3. Function to calculate # of books to be ordered, function to calculate profit, and function to output everything.
The things I need help with are:
1. Something is wrong with my logic statements for whether the book is suggested, required, new or old and I am unsure of what it is.
2. How do I use the exit functions correctly so that if someone enters 'Q' when it asks for 'R' or 'S' the program aborts?
3. I get a warning on line 70: "Passing argument 1 of 'profit' makes integer from pointer without a cast". I have very little understanding of what this means and absolutely no idea how to fix it.
4a. What am I supposed to put for the return parameter for my 'output' function? It is supposed to output three print statements.
4b. When calling output() in main, what am I supposed to put inside the parentheses?
Thanks in advance!!!
-LowKey Variation in Production
Code:
#include <stdio.h>
#include <stdlib.h>
#define STORE_PROFIT .2
//Function Prototypes
int books(double, char, char);
float profit(int, float);
void output(int num);
int main(void)
{
//Declare Variables
//ISBN
char i1;
char i2;
char i3;
char i4;
char i5;
char i6;
char i7;
char i8;
char i9;
char i10;
//Text Code
char rs; //Required or Suggested
char r; //Required
char s; //Suggested
char no; //New or Old
char n; //New
char o; //Old
//Other
double lp; //List Price
double ee; //Expected Enrollment
//Input
printf("Enter ISBN number: ");
scanf(" %c %c %c %c %c %c %c %c %c %c", &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8, &i9, &i10);
printf("Enter price per copy: ");
scanf(" %lf", &lp);
printf("Enter expected class enrollment: ");
scanf(" %lf", &ee);
printf("Enter 'R' if required or 'S' if suggested: ");
scanf(" %c", &rs);
rs = tolower(rs);
if (rs = r)
r = rs;
else if (rs = s)
s = rs;
else exit(0);
printf("Enter 'N' if new or 'O' if not a new text: ");
scanf(" %c", &no);
no = tolower(no);
if (no = n)
n = no;
else if (no = o)
o = no;
else exit(0);
//Compute
books (ee, rs, no);
profit (books, STORE_PROFIT);
//Output
output (0);
return 0;
}//main---------------------------------------------------------------------------------------------------------------------
//Number of Books Function
int books(double expect, char rs, char no)
{
//Pre: Expected Enrollment and whether r/s and n/o
//Post: Books needed
//Local Declarations
char r; //Required
char s; //Suggested
char n; //New
char o; //Old
int ex; //Expected Enrollment
int need; //Books needed
//Logic Statements
if (rs = r)
if (no = n)
need = .9 * ex;
else if (no = o)
need = .65 * ex;
else if (rs = s)
if (no = n)
need = .4 * ex;
else if (no = o)
need = .2 * ex;
return need;
}//number of books function-------------------------------------------------------------------------------------------------
//Calculate Profit Function
float profit(int needed, float stoprof)
{
//Pre: List price & Copies needed
//Post: Bookstore's profit
//Local Declarations
float prof; //Profit
float sdlp; //Store discount off list price
int need; //Books needed
//Compute
prof = sdlp * need;
return prof;
}//profit function-----------------------------------------------------------------------------------------------------------
//Output Function
void output(int num)
{
//Pre: Data
//Post: Output ISBN, copies needed and profit
//Local Declarations
char i1;
char i2;
char i3;
char i4;
char i5;
char i6;
char i7;
char i8;
char i9;
char i10;
int need;
float prof;
printf("\n\nISBN: %c-%c%c-%c%c%c%c%c%c-%c", i1, i2, i3, i4, i5, i6, i7, i8, i9, i10);
printf("Copies Needed: %d", need);
printf("Profit: $6.2f", prof);
}//output function-----------------------------------------------------------------------------------------------------------