text: Hi, I need help in understanding nested loops. Here's my problem.
  I'm asked to write a code that emulates a cash register. Using only while loops and do while loops, and can be with the help of if/else statements.
  Desired output :
  Welcome to CrappyMart
  type (-1) when done to calculate total:
  Enter the price of 1st article : xx.xx
  Subtotal: $xx.xx
  Enter the price of 2nd article: xx.xx
  Subtotal: $xx.xx
  Enter the price of 3rd article: -xx.xx
  OOPS Wrong Value entered.
  Enter the price of 3rd article: xx.xx
  Enter the price of the 4th article: -1
  The total is : $ 50.00
  The total number of items purchased is: XX
  Enter the payment amount : $40.00
  The amount is lower than the total of your purchase
  Enter the payment amout: $60.00
  Your change is $10.00
  Thank you for shopping at CrappyMart.
  Here's what I have so far. Can someone guide me into the light of the right direction. :'(
  Surprisingly enough the code I wrote compiles but it doesn't gives the desired output =( :@
  #include <iostream> using namespace std; int main () { double itemPrice, subTotal, payment; double change; int nItems; //counter nItems = 1; itemPrice = 0.0; subTotal = 0.0; payment = 0.0; cout << " Enter the price of the purchase " <<endl; cout << " Press ( -1 ) to exit and calculate total" <<endl; do { if (itemPrice < 0 ) { cout<< "Not an accepted price" <<endl; } cout << "Enter the price of article number "<<nItems<<" in dollars $"; cin >> itemPrice; } while (itemPrice < 0); cout<<"Enter the price of the item number"<<nItems<<"in dollars $"; cin>>itemPrice; if (itemPrice > 0){ subTotal = subTotal + itemPrice; ++nItems; } else (itemPrice == -1); cout <<" The total is: $" <<subTotal; cout <<" The number of items is: "<<nItems; cout <<" Enter the payment amout $"<<payment; cin >> payment; do { if (payment < subTotal) { cout <<"The amount is lower than the total"<<endl; } cout<<"Enter the payment amount $"<<endl; cin >> payment; } while (payment < subTotal); change = subTotal - payment; cout<<"Your change is $"<<change; cin.get(); return 0; }