I have a code that generates random double numbers but how do I make it generate the random numbers as such? 10.00 instead of 10.0000 (too many 0's!)
if (newmonster.gethealth() < 1)
{
random_device rd;
mt19937 gen(rd());
uniform_real_distribution<> rand(3.00, 6.00);
double amount = rand(gen);
newplayer.playercash += amount;
cout << "You have killed a Level " << newmonster.getlevel() << " " << newmonster.getname() << ". You've earned $" << amount << " cash." << endl;
newmonster.monsterspawned = 0;
goto home;
}
More clearly, here is what I want the script to do:
Aucun commentaire:
Enregistrer un commentaire