C++/프로그램 연습

커피 주문하기

appmaster 2020. 9. 30. 12:55

#include <stdio.h>
#include <iostream>
#include <string>
#include <windows.h>

using namespace std;


int main(void) {

	int espresso = 2000;
	int americano = 2300;
	int cappucino = 2500;
	int total = 0;
	string order;


	cout << "에스프레소 2000원, 아메리카노 2300원, 카푸치노 2500원 입니다. 종료하고 싶으시면 no와 0을 입력하세요\n주문>>";

	while (1) {
		cin >> order >> total;

		if (order == "에스프레소" && total >= 0) {
			cout << total * espresso <<"원 입니다. 맛있게 드세요";
		}
		else if (order == "아메리카노" && total >= 0) {
			cout << total * americano << "원 입니다. 맛있게 드세요";
		}
		else if (order == "카푸치노" && total >= 0) {
			cout << total * cappucino << "원 입니다. 맛있게 드세요";
		}
		else if (order == "no" && total == 0) {
			break;
		}
		else {
			cout << "잘못입력하셨습니다";
		}

		cout << "\n주문>>";
	}

	return 0;
}

'C++ > 프로그램 연습' 카테고리의 다른 글

Tower 실습하기  (0) 2020.09.30
은행계좌 파일나눠서 써보기 (account.h, account.cpp, main.cpp)  (0) 2020.09.30
은행계좌 만들기  (0) 2020.09.30