Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace UTS2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int[] Dadu1 = new int[7];//membuat array dadu 1
- int[] Dadu2 = new int[7];//membuat array dadu 2
- int lempar;//inisialisasi lempar
- int lemparan = Int16.Parse(textBox1.Text);//inisialisasi lemparan
- Random roll = new Random();//RNG
- for (lempar = 1; lempar <= lemparan; lempar ++)//looping statement
- {
- Dadu1[roll.Next(1, 7)]++;//RNG
- Dadu2[roll.Next(1, 7)]++;//RNG
- }
- for (int side = 1; side < Dadu1.Length; side++)//looping statemnet
- {
- textBox2.Text+=(Dadu1[side])+" ";//output ke textbox per roll
- }
- for (int side = 1; side < Dadu2.Length; side++)//looping statement
- {
- textBox3.Text+=(Dadu2[side])+" ";//output ke textbox
- }
- int total = Dadu1.Sum() + Dadu2.Sum();//aritmarika total jumlah sisi dadu
- textBox4.Text=Convert.ToString(total);//output ke textbox
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement