ISYS 350, Assignment 2, Part 1

ISYS 350, Assignment 2,

Part 1:

Create a C# Form with a textbox and a button. The box isfor a user to enter a number

of seconds. And when the user clicks the button, theprogram displays the equivalent

number of hours, minutes and seconds using a MessageBox.Show method. If the

seconds entered is less than 60, your program shouldonly display the seconds; if the

seconds is a least 60 and less than 3600, your programshould display minutes and

seconds; if the second is at least 3600, your programshould display hours, minutes

and seconds.

Use the following data to test yourprogram:

47 seconds: 47 seconds (don’t show 0 hour and 0minute)

645 seconds: 10 minutes, 45 seconds (don’t show 0hour)

7565 seconds: 2 hours, 6 minutes, 5 seconds

Requirements:

1. Input validation: The number of seconds cannot exceed86400. You must use

textbox’s Validating event to do thevalidation.

2. Turn in the form’s screenshot and the code. (Note:You can use the Alt

+ PrintScrn keys to capture only the activewindow.)

Part 2: An electric company charges to their customersbased on Kilowatt-Hours

(Kwh) used. The rules to compute the chargeare:

First 100 Kwh, 35 cents per Kwh

Each of the next 100 Kwh (up to 200 Kwh), 45 cents perKwh

(the first 100 Kwh used is still charged at 35 centseach)

Each of the next 300 Kwh (up to 500 Kwh) 65 cents perKwh

All Kwh over 500, 80 cents per KH

Create a C# Form with a textbox to enter Kwh used, aread-only textbox to display the

electricity charges, and a button to compute thecharges. The Kwh used could be a

number with decimals.

Requirements:

1. Input validation: Use the KWH textbox validatingevent to ensure the KWH cannot

exceed 2000. Test your program with (1) Kwh=4500, (2)Kwh = 350

2. Turn in the form’s screenshot and thecode

Answer:

Code:-

1)

using System;

using System.Windows.Forms;

namespace ProgramToConvertSecondsToMinutesHours

{

    public partial class CalculteTime :Form

    {

        intmySeconds;

        publicCalculteTime()

        {

            InitializeComponent();

        }

        private voidbtnTime_Click(object sender, EventArgs e)

        {

            mySeconds= System.Convert.ToInt32(txtTime.Text);

            MessageBox.Show(ConvertToTime(mySeconds));

        }

        public stringConvertToTime(int timeInSeconds)

        {

            intmyHours = mySeconds / 3600;

            mySeconds%= 3600;

            intmyMinutes = mySeconds / 60;

            mySeconds%= 60;

            stringmySec = mySeconds.ToString(),

            myMin= myMinutes.ToString(),

            myHou= myHours.ToString();

            if(myHours< 10)

            {

                myHou= myHou.Insert(0, “0”);

            }

            if(myMinutes< 10)

            {

                myMin= myMin.Insert(0, “0”);

            }

            if(mySeconds< 10)

            {

                mySec= mySec.Insert(0, “0”);

            }

            if(myMinutes== 0 && myHours == 0)

            {

                returnmySec + ” Seconds”;

            }

            elseif (myHours == 0)

            {

                returnmyMin + ” Minutes” + ” ,” + mySec + ” Seconds”;

            }

            else

            {

                returnmyHou + ” Hours” + ” , ” + myMin + ” Minutes” + ” , ” + mySec + “Seconds”;

            }

        }

        private voidtxtTime_MouseLeave(object sender, EventArgs e)

        {

            mySeconds= System.Convert.ToInt32(txtTime.Text);

            if(mySeconds > 86400)

            {

                MessageBox.Show(“Entervalid time in seconds (less than 86400)”);

            }

        }

    }

}

Code Screenshots:-

2)

using System;

using System.Windows.Forms;

namespace ProgramToConvertSecondsToMinutesHours

{

    public partial class Electricity_Charge: Form

    {

        publicElectricity_Charge()

        {

            InitializeComponent();

        }

        private voidElectricity_Charge_Load(object sender, EventArgs e)

        {

        }

        private voidtxtElectricity_MouseLeave(object sender, EventArgs e)

        {

            doubleelectricityInKwh = double.Parse(txtElectricity.Text);

            if(electricityInKwh > 2000)

            {

                MessageBox.Show(“Electricityvalue can not exceed than 2000”);

            }

        }

        private voidbtnCharge_Click(object sender, EventArgs e)

        {

            doubleelectricityInKwh = double.Parse(txtElectricity.Text);

            txtElectricityCharge.Text=calculateCharge(electricityInKwh);

        }

        public stringcalculateCharge(double electricityInKwh)

        {

            doubleamount;

            if(electricityInKwh <= 100)

            {

                amount= electricityInKwh * 35;

            }

            elseif (electricityInKwh <= 200)

            {

                amount= 2500 + ((electricityInKwh – 100) * 45);

            }

            elseif (electricityInKwh <= 500)

            {

                amount= 6000 + ((electricityInKwh – 200) * 65);

            }

            else

            {

                amount= 16000 + ((electricityInKwh – 500) * 80);

            }

            returnamount.ToString();

        }

    }

}

Code Screenshots:-

Please UPVOTE thank you…!!!


 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"
Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with brilliantassignmenthelp.com
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat
Close

Sometimes it is hard to do all the work on your own

Let us help you get a good grade on your paper. Get professional help and free up your time for more important courses. Let us handle your;

  • Dissertations and Thesis
  • Essays
  • All Assignments

  • Research papers
  • Terms Papers
  • Online Classes