I have created this code for my class and I have worked on it for a week without it working. The program compiles, but the output is not correct. I believe that my parameters are the problem, but I have researched many questions on this forum and two other discussion forums. The questions being asked did not help me with my situation.
*/
#include <iostream>
#include <cmath>
using namespace std ;
void Instructions () ;
int numBooks (int) ;
float totalCost (int, float) ;
float percentoff (float, float) ;
float finalCost (float, float, float) ;
float receipt (int, float, float, float) ;
int main ()
{
int books ;
float total, cost, discount, novels ;
Instructions () ;
numBooks (books) ;
totalCost (books, total) ;
percentoff (total, discount) ;
finalCost (discount, total, cost) ;
receipt (books, total, discount, cost) ;
}
void Instructions ()
{
cout << "This program will ask for the number of books being purchased. It will then calculate your discount, and provide the total cost." << endl ;
}
int numBooks (int books)
{
cout << endl << "Enter the number of books you wish to purchase." << endl ;
cin >> books ;
return books ;
}
float totalCost (int books, float total)
{
float price = 8.99 ;
total = books * price ;
return (total) ;
}
float percentoff (float total, float discount)
{
float percent = 0.15 ;
discount = percent * total ;
return (discount) ;
}
float finalCost (float discount, float total, float cost)
{
cost = total - discount ;
return (cost) ;
}
float receipt (int books, float total, float discount, float cost)
{
cout << books << endl ;
cout << "$" << total << endl ;
cout << discount << "% off" << endl ;
cout << "$" << cost << endl ;
}