0% found this document useful (0 votes)
31 views

main Program: Using Using Using Using Using Using Using Using Namespace Public Partial Class New Public

The document contains code for a program with a form that takes hour, minute, and second values as text box inputs. It has a sub class with methods to add time by incrementing values, check for invalid inputs, and convert 24-hour times to 12-hour format. Buttons on the form call methods to set time values, run the time and error checking methods, and display outputs.

Uploaded by

Nathaniel Cailo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views

main Program: Using Using Using Using Using Using Using Using Namespace Public Partial Class New Public

The document contains code for a program with a form that takes hour, minute, and second values as text box inputs. It has a sub class with methods to add time by incrementing values, check for invalid inputs, and convert 24-hour times to 12-hour format. Buttons on the form call methods to set time values, run the time and error checking methods, and display outputs.

Uploaded by

Nathaniel Cailo
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

//Main Program

using using using using using using using using System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms;

namespace actual3 { public partial class Form1 : Form { sub s1 = new sub(); public Form1() { InitializeComponent();

} private void button1_Click(object sender, EventArgs e) { s1.h = int.Parse(textBox1.Text); s1.e = int.Parse(textBox1.Text); s1.hour(); label9.Text = "" + s1.h; label8.Text = "" + s1.h; label7.Text = textBox1.Text; } private void button2_Click(object sender, EventArgs e) { s1.m = int.Parse(textBox2.Text); s1.error(); label15.Text = "" + s1.m; label14.Text = "" + s1.m; label13.Text = textBox2.Text; } private void button3_Click(object sender, EventArgs e) { s1.s = int.Parse(textBox3.Text); s1.error(); label21.Text = "" + s1.s; label20.Text = "" + s1.s; label19.Text = textBox3.Text; } private void button4_Click(object sender, EventArgs e) { s1.add(); s1.hour(); s1.error(); label9.Text = "" + s1.h; label8.Text = "" + s1.h; label7.Text = "" + s1.e; label15.Text = "" + s1.m; label14.Text = "" + s1.m; label13.Text = "" + s1.m; label21.Text = "" + s1.s; label20.Text = "" + s1.s; label19.Text = "" + s1.s; textBox1.Text = "" + s1.h; textBox2.Text = "" + s1.m; textBox3.Text = "" + s1.s; } } }

using using using using using

System; System.Collections.Generic; System.Linq; System.Text; System.Windows.Forms;

namespace actual3 { class sub { public int h, m, s, e; public void add() { if (s == 59) { m = m + 1; s = 0; } else { s = s + 1; } if (m > 59) { h = h + 1; m = 0; e = e + 1; } } public void hour() { if (h > 24) { MessageBox.Show("Please enter correct input."); h = 0; } if (h == 13) { h = 1; } if (h == 14) { h = 2; } if (h == 15) { h = 3; } if (h == 16) { h = 4; } if (h == 17) { h = 5; } if (h == 18) {

h } if (h { h } if (h { h } if (h { h } if (h { h } if (h { h } if (h { h }

= 6; == 19) = 7; == 20) = 8; == 21) = 9; == 22) = 10; == 23) = 11; == 24) = 12;

} public void error() { if (m > 60 || s > 60) { MessageBox.Show("Please enter correct input"); m = 0; s = 0; } } } }

//Main Program
using using using using using System; System.Collections.Generic; System.Linq; System.Text; System.Windows.Forms;

namespace actual3 { class sub { public int h, m, s, e; public void add() { if (s == 59) { m = m + 1; s = 0; } else { s = s + 1; } if (m > 59) { h = h + 1; m = 0; e = e + 1; } } public void hour() { if (h > 24) { MessageBox.Show("Please enter correct input."); h = 0; } if (h == 13) { h = 1; } if (h == 14) { h = 2; } if (h == 15) { h = 3; } if (h == 16) { h = 4; } if (h == 17) { h = 5;

} if (h { h } if (h { h } if (h { h } if (h { h } if (h { h } if (h { h } if (h { h }

== 18) = 6; == 19) = 7; == 20) = 8; == 21) = 9; == 22) = 10; == 23) = 11; == 24) = 12;

} public void error() { if (m > 60 || s > 60) { MessageBox.Show("Please enter correct input"); m = 0; s = 0; } } } }

You might also like