#include<iostream>
int main(){
int total, quantity, price;
char customer = 'Y';
total = 0;
do{
std::cout << "Customer: " << customer << std::endl;
std::cout << "Input a quantity: " << std::endl;
std::cin >> quantity;
if(std::cin.fail()){
std::cin.clear();
std::cin.ignore(255, '\n');
continue;
}
std::cout << "Input a price: " << std::endl;
std::cin >> price;
if(std::cin.fail()){
std::cin.clear();
std::cin.ignore(255, '\n');
continue;
}
total += price * quantity;
std::cout << "Continue for another customer? ('n' or 'N' to exit)" << std::endl;
std::cin >> customer;
if(customer == 'N' || customer == 'n')break;
}while(customer != 'n' || customer != 'N');
std::cout << std::endl;
std::cout << std::endl;
std::cout << "Total paid for all customers: " << total << std::endl;
return EXIT_SUCCESS;
}
Comments
Leave a comment