Very basic pizza ordering program

Im having trouble calculating the total amount due. Here's my code:


#include <iostream>
using std::cout;
using std::endl;
using std::cin;
using std::string;

main() {

int mediump ;
int largep ;
double TotalCharge ;
double amtrec ;
const double c12in = 12.39 ;
const double c14in = 15.98 ;

TotalCharge = (mediump * c12in) + (largep * c14in) ;

cout << "Welcome to Pizza Palace! " << endl;

cout << "How Many 12 inch Pizzas would you like?" << endl;

cin >> mediump;

cout << "How Many 14 inch Pizzas would you like?" << endl;

cin >> largep ;

cout << "Total amount due is: " << "$" << TotalCharge << endl;

cout << "Enter Amount Recieved: " << endl;

cin >> amtrec ;

cout << "Change due: " << (amtrec - TotalCharge) << endl;



}


The total amount due comes out to zero and I don't know what im doing wrong. any help is appreciated.
C++ is a procedural language. Although the line TotalCharge = (mediump * c12in) + (largep * c14in) ; makes sense logically, C++ doesn't "think" like you do. That line needs to be put under the statements that ask for mediump and largep, and before you print TotalCharge. Where that line is now, mediump and largep still have their default values (for numbers that's 0.)

http://en.wikipedia.org/wiki/Procedural_programming
Last edited on
Thanks for the help!
Topic archived. No new replies allowed.