# Why is my output at the end screwed up?

I’m writing a program for my class, and I don’t understand why the printResults at the end displays the numbers in this way. I checked the formulas and everything, and I’ve compared it to my friends’ code, and we don’t see anything wrong!
Why do the numbers for the discount and total cost show up like this?

``````#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

///function declarations
void printInstructions();
int getNumberOfBooks();
double calculateSubtotal (int numberOfBooks, double bookPrice);
double calculateDiscount (double subtotal, double discount);
double calculateTotalCost (double subtotal, double discount);
void printResults (int numberOfBooks, double subtotal, double totalDiscount, double totalCost);

int main ()
{
///variables
int numberOfBooks;
double subtotal;
double discount = .15;
double bookPrice = 8.99;
double totalDiscount;
double totalCost;
///functions and parameters
printInstructions();
numberOfBooks = getNumberOfBooks();
subtotal = calculateSubtotal (numberOfBooks, bookPrice);
discount = calculateDiscount (subtotal, discount);
totalDiscount = (subtotal, totalDiscount);
totalCost = calculateTotalCost (subtotal, totalDiscount);
printResults (numberOfBooks, subtotal, totalDiscount, totalCost);

return 0;

}

void printInstructions()
{
cout <<"Hello, we are having a special deal on ebooks.";
total price will be.";
cout << "You will first be asked to input the number of books you will download, then this \
program will calculate the subtotal for those books.";
cout  << "Afterwards, this program will calculate the disco\
unt for the order, and ultimately it will calculate the total cost for the downloaded books.";
cout  << "The information will be displayed to you at the end." << endl;
}
int getNumberOfBooks()
{ int numberOfBooks;
cout <<"How many books will you purchase today?" << endl;
cin >> numberOfBooks;
cout <<"You will purchase " << numberOfBooks << " book(s).\n\n ";
return numberOfBooks;
}
double calculateSubtotal (int numberOfBooks, double bookPrice)
{ double subtotal;
subtotal = numberOfBooks * bookPrice;
return subtotal;
}
double calculateDiscount (double subtotal, double discount)
{ double totalDiscount;
totalDiscount = (subtotal * discount);
}

double calculateTotalCost (double totalDiscount, double subtotal)
{ double totalCost;
totalCost = subtotal - totalDiscount;
}

void printResults (int numberOfBooks, double subtotal, double totalDiscount, double totalCost)
{
cout <<"Number of books to be downloaded is: " << numberOfBooks << endl ;
cout <<"The subtotal for the books is: " << subtotal << endl;
cout <<"The discount is: " << setprecision(2)<<  totalDiscount << endl;
cout <<"The total cost for the books is: " << setprecision(2) << totalCost << endl;

}

``````