Docsity

OOP kontrolne vezbe -1, Vežbe od Računarstvo i informatika

Toggle sidebar
bg1
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 Levang
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int matijas;
int Nmatijas;
int ZBmatijas = 0;
private void button1_Click(object sender, EventArgs e)
{
if (textBox1matijas.Text == "")
MessageBox.Show("Niste uneli broj brojeva!");
else
if (Convert.ToInt32(textBox1matijas.Text) > 9)
{
MessageBox.Show("Unesite broj manji od 9!");
textBox1matijas.Clear();
}
else
if (Convert.ToInt32(textBox1matijas.Text) <= 9)
{
Nmatijas = Convert.ToInt32(textBox1matijas.Text);
for (int i = 1; i <= Nmatijas; i++)
{
listBox1matijas.Items.Add(i);
}
button1.Enabled = false;
textBox1matijas.Enabled = false;
}
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox2matijas.Text == "")
MessageBox.Show("Niste uneli broj!");
else
{
if (Convert.ToInt32(textBox2matijas.Text) % 2 == 0)
{
listBox1matijas.Items.Add(textBox2matijas.Text);
textBox2matijas.Clear();
}
else
{
pf2

Delimični pregled teksta

Preuzmite OOP kontrolne vezbe -1 i više Vežbe u PDF od Računarstvo i informatika samo na Docsity!

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 Levang { public partial class Form1 : Form { public Form1() { InitializeComponent(); } int matijas; int Nmatijas; int ZBmatijas = 0; private void button1_Click(object sender, EventArgs e) { if (textBox1matijas.Text == "") MessageBox.Show("Niste uneli broj brojeva!"); else if (Convert.ToInt32(textBox1matijas.Text) > 9) { MessageBox.Show("Unesite broj manji od 9!"); textBox1matijas.Clear(); } else if (Convert.ToInt32(textBox1matijas.Text) <= 9) { Nmatijas = Convert.ToInt32(textBox1matijas.Text); for (int i = 1; i <= Nmatijas; i++) { listBox1matijas.Items.Add(i); } button1.Enabled = false; textBox1matijas.Enabled = false; } } private void button2_Click(object sender, EventArgs e) { if (textBox2matijas.Text == "") MessageBox.Show("Niste uneli broj!"); else { if (Convert.ToInt32(textBox2matijas.Text) % 2 == 0) { listBox1matijas.Items.Add(textBox2matijas.Text); textBox2matijas.Clear(); } else {

listBox2matijas.Items.Add(textBox2matijas.Text); textBox2matijas.Clear(); } } } private void button3_Click(object sender, EventArgs e) { if (Convert.ToInt32(textBox2matijas.Text) > Nmatijas) { textBox2matijas.Enabled = false; button2.Enabled = false; matijas = Convert.ToInt32(textBox2matijas.Text); for (int i = Nmatijas; i <= matijas; i++) { if (i % 5 == 0) ZBmatijas += i; } MessageBox.Show("Zbir brojeva deljivih sa pet od " + Nmatijas + " do " + matijas + " je " + ZBmatijas); button3.Enabled = false; button4.Enabled = true; } } private void button4_Click(object sender, EventArgs e) { button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; button4.Enabled = false; textBox1matijas.Enabled = true; textBox2matijas.Enabled = true; textBox1matijas.Clear(); textBox2matijas.Clear(); listBox1matijas.Items.Clear(); listBox2matijas.Items.Clear(); Nmatijas = 10; matijas = 0; ZBmatijas = 0; } private void Form1_Load(object sender, EventArgs e) { } } }