Skip to content
Snippets Groups Projects
Commit 96c9066a authored by Rudi Buss's avatar Rudi Buss
Browse files

Update Exercise 1 - Euro.txt

parent 02c9e137
No related branches found
No related tags found
No related merge requests found
Overload operators '+', '-' and '*' so that the program below can be compiled. Also write a function Òoutput()Ó that outputs the amount. The cent amount must not be negative (if it is, the euro amount is reduced accordingly) and the cent amount must not be in three digits (the euro amount increases until the cent amount is in two digits). The interest rate increases the euro/cent amount by the respective factor. #include <iostream> #include <cstdlib> using namespace std; class euro { private: int euro; int cent; }; int main() { Euro myMoney(100.80), yourMoney(45.30), fine(25.80), ourMoney; double interestrate = 3.5; ourMoney = myMoney + yourMoney; ourMoney.output(); ourMoney = ourMoney - fine; ourMoney.output(); ourMoney = ourMoney.operator*(interestrate); ourMoney.output(); system("pause"); return 0; }
\ No newline at end of file
Overload operators '+', '-' and '*' so that the program below can be compiled.
Also write a function "output()" that outputs the amount.
The cent amount must not be negative (if it is, the euro amount is reduced accordingly) and
the cent amount must not be in three digits (the euro amount increases until the cent amount is in two digits).
The interest rate increases the euro/cent amount by the respective factor.
#include <iostream>
using namespace std;
class euro
{
private:
int euro;
int cent;
};
int main()
{
Euro myMoney(100.80), yourMoney(45.30), fine(25.80), ourMoney;
double interestrate = 3.5;
ourMoney = myMoney + yourMoney;
ourMoney.output();
ourMoney = ourMoney - fine;
ourMoney.output();
ourMoney = ourMoney.operator*(interestrate);
ourMoney.output();
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment