Write a program to display a a multiplication table such as young children use. A program should be capable of displaying a table of any size, specified by an integer entered into a text box.
1
Expert's answer
2012-09-14T10:48:46-0400
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms;
namespace Table { public partial class Form1 : Form { & int x, y; & public Form1() & { InitializeComponent(); & }
& private void buttonShowTable_Click(object sender, EventArgs e) & { StringBuilder table = new StringBuilder(); x = Convert.ToInt32(textBoxX.Text); y = Convert.ToInt32(textBoxY.Text);
for (int i = 1; i < x+1; i++) { for (int j = 1; j < y+1; j++) { & table.Append(i.ToString()+" x "+j.ToString()+" = "+(i*j).ToString()+";\n"); } table.Append("======================\n"); } textboxOutput.Text = table.ToString(); & } } }
Comments
Leave a comment