0

I was in the library's multimedia room to do my assignment, but all PCs don't have Visual Studio and other smiliar programs. So I wrtie the code on Notepad for the question:

Design a solution that will determine and display the fewest number of ringgit and coins in change of a purchase value. The customer may pay any amount for the purchase. The changes are in the form of 1 cent, 5 cents, 10 cents, 50 cents, RM1, RM5, RM10 and RM50.

The following is an example of the solution result.

Purchase : RM 23.63

Payment : RM 100.00

Change : RM 76.37RM50 = 1

RM10 = 2

RM5 = 1

RM1 = 1

50 cents = 0

10 cents = 3

5 cents = 1

1 cents = 2

```
/*
C++ code for Part B Q1
*/
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
//variable declaration
int FiftyRinggit, TenRinggit, FiveRinggit, Ringgit, FiftyCents, TenCents, FiveCents, Cent;
float PurchasePrice, Payment, Change;
//input or prompt
cout<<"-----------------PURCHASE AND CHANGE-----------------\n";
cout<<"Purchase : RM";
cin>>PurchasePrice;
cout>>"Payment : RM";
cin>>Payment;
//process
Change = Payment - PurchasePrice;
//convert
Cent = Change * 100;
//figure out how much change is owed
//Number of RM50 notes
FiftyRinggit = Cent / 5000;
Cent = Cent - (FiftyRinggit * 5000);
//Number of RM10 notes
TenRinggit = Cent / 1000;
Cent = Cent - (TenRinggit * 1000);
//Number of RM5 notes
FiveRinggit = Cent / 500;
Cent = Cent - (FiveRinggit * 500);
//Number of RM1 notes
Ringgit = Cent / 100;
Cent = Cent - (Ringgit * 100);
//Number of 50 cents coins
FiftyCents = Cent / 50;
Cent = Cent - (FiftyCents * 50);
//Number of 10 cents coins
TenCents = Cent / 10;
Cent = Cent - (TenCents * 10);
//Number of 5 cents coins
FiveCents = Cent / 50;
Cent = Cent - (FiveCents * 5);
//output
cout<<"Change : RM"<<Change<<endl
cout<<"RM50="<<FiftyRinggit
cout<<"RM10="<<TenRinggit
cout<<"RM5="<<FiveRinggit
cout<<"RM1="<<Ringgit
cout<<"50 cents="<<FiftyCents
cout<<"10 cents="<<TenCents
cout<<"5 cents="<<FiveCents
cout<<"1 cent="<<Cent<<endl
cout<<"--------------------------END------------------------"<<endl;
system("pause");
return 0;
}
```

Does it look correct or not?