Answer to Question #248687 in C++ for Kundie's

Question #248687
use appropriate pointer operator to print the addresses of the numbers in memory, the memory address must be expressed in hexadecimal
After the addresses of the numbers ,use the deferencing operator to point to values contained within addresses. Use the function sort with begin() and end() function to organize the values in ascending order.After establishment the order of values ,assign values into an array called winning-numbers. You can use the statement or the initializer list to initialize
The amounts won must be determined by custom made function called amountDeterminant of type double and receives a double argument in prototype, the argument will be the winning number received from the sum of two (2)
Amount Determination must use switch conditions and operate as follows :
If the winning number is ,
1. Between 80 and 83 , the won amount is R1700000-00
2. Between 84 and 86, the won amount is R2 50000-00
3. Between 87 and 98, the won amount is R16000000-00
1
Expert's answer
2021-10-08T23:51:15-0400


#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; 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS