Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main() {
- //Challenge: Create a program to roll any amount of dice with any amount of sides. 3d6 stuff.
- srand(time(NULL));
- int sides;
- int amount;
- int roll;
- int total = 0;
- char yn;
- do{
- std::cout << "**DND Dice**\n";
- std::cout << "Please input the number of sides. ";
- std::cin >> sides;
- std::cout << "Input the amount of dice to roll. ";
- std::cin >> amount;
- std::cout << "You are rolling " << amount << "d" << sides << ". Is this correct? Y/N ";
- std::cin >> yn;
- if(yn == 'Y') {yn = 'y';}
- }while(yn != 'y');
- for(int i = 0; i < amount; i++) {
- roll = rand() % sides + 1;
- std::cout << roll << '\n';
- total += roll;
- }
- std::cout << "Total: " << total;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement