📄 currency.cpp
字号:
// Exercise 11.2 Currency converter. File: currency.cpp
#include <iostream>
#include <iomanip>
#include "currency.h"
// Display a currency amount with two decimal places
void Currency::show() {
std::cout << std::fixed << std::setprecision(2) << amount << " " << code;
}
// Sets the amount for the current currency
void Currency::set_amount(double value){
if(value == 0.0) // Can't have a zero amount
amount = 1.0;
else
amount = value;
}
// Convert the amount of the current currency the currency of the argument
double Currency::convert(Currency currency) {
return amount*rate/currency.rate;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -