#include<cstdlib>
#include <iostream>
#include <algorithm>
#include<ctime>
#include <iomanip>
using namespace std;
double amountDeterminat(int win);
int main()
{
srand(time(NULL));
int random_numbers[6];
for(int i=0;i<6;i++){
random_numbers[i] = rand() % 50;
}
sort(begin(random_numbers),end(random_numbers));
cout<<"Address of elements memory\n";
for(int i=0;i<6;i++){
cout<<&random_numbers[i]<<" ";
}
cout<<"\nRandom Numbers are: \n";
for(int i=0;i<6;i++){
cout<<random_numbers[i]<<" ";
}
int win=0;
for(int i=0;i<5;i++){
int total=random_numbers[i]+random_numbers[i+1];
if(total>=80){
win=total;
}
}
cout<<"\n\n";
if(win!=0){
cout<<"You won.\n";
cout<<fixed<<"Won amount: "<<setprecision(2)<<"R "<<amountDeterminat(win)<<"\n";
}else{
cout<<"You loose.\n\n";
}
cout<<"\n";
return 0;
}
double amountDeterminat(int win){
switch(win){
case 80 ... 83:
return 1700000.00;
break;
case 84 ... 86:
return 2500000.00;
break;
case 87 ... 98:
return 16000000.0;
break;
}
return 0;
}
Comments
Leave a comment