import random
dice = random.randint(1,6)
print(dice)
count = 1
while dice != 6:
count += 1
print('You got 6!')
print('You rolled',count,'times')
#Click 'Run' to try again
#Python
xxxxxxxxxx
let dice = Math.ceil(Math.random()*6);
console.log(dice);
let count = 1;
while (dice != 6) {
dice = Math.ceil(Math.random()*6);
count += 1;
}
console.log('You got 6!');
console.log('You rolled',count,'times');
//Click 'Run' to try again
//JavaScript
public class Main {
public static void main(String[] args) {
java.util.Random random = new java.util.Random();
int dice = random.nextInt(6) + 1;
System.out.println(dice);
int count = 1;
dice = random.nextInt(6) + 1;
count++;
System.out.println("You got 6!");
System.out.println("You rolled " + count + " times");
//Java
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;
int main() {
srand(time(nullptr));
int dice = rand() % 6 + 1;
cout << to_string(dice) + "\n";
dice = rand() % 6 + 1;
cout << "You got 6!\n";
cout << "You rolled " + to_string(count) + " times\n";
return 0;
//C++