In: Computer Science
Create a module to calculate the amount of royalties that Parker Schnabel must pay Tony Beets at the end of the gold mining season based on the following contractual agreement. When the amount of gold mined is 3000 ounces or less the rate is 15% of the gold value. This lower royalty rate is stored in a variable named lowerRate. When the amount of gold mined is greater than 3000 ounces the royalty rate is 20%. This higher rate is stored in a variable named goldRushRate and is applied only to the amount over 3000 ounces. The price of gold is currently $1200.00. This amount is stored in a variable defined as priceGold. The number of ounces mined is stored in a variable integer ouncesMined. You should ask Parker to input the number of ounces that he mined this season and print out “Based on x ounces mined, you paid y in royalties.” You will need to multiply the ounces of gold mined by the price by the royalty rate to produce the proper royalties.
//This is c++ code
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int ouncesMined = 0;
/*The price of gold is currently $1200.00. */
double lowerRate=0, priceGold = 1200.00 ,
goldRushRate=0,royaltyRate=0;
/* The number of ounces mined is stored in
a variable integer ouncesMined.
You should ask Parker to input the
number of ounces that he mined*/
cout << "Enter the number of ounces mined in
this season: ";
cin >> ouncesMined;
/* When the amount of gold mined is 3000 ounces
or
less the rate is 15% of the gold value. */
if (ouncesMined <= 3000)
{
lowerRate = 0.15;
royaltyRate = priceGold *
ouncesMined * lowerRate;
}
/*. When the amount of gold mined is greater
than 3000 ounces the royalty rate is 20%.*/
else
{
goldRushRate = 0.20;
royaltyRate =
3000*0.15*priceGold+(ouncesMined - 3000) * priceGold *
goldRushRate;
}
cout << fixed << setprecision(2);
cout << "Royalty = $" << royaltyRate
<< endl;
//pause
system("pause");
return 0;
}
//Output
if you need any help regarding this solution....... please leave a comment ......... thanks