In this lab you will be creating a small program that looks

In this lab, you will be creating a small program that looks like the keypad of a calculator. You should try to recreate the screenshot on the next page. For reference, the frame is 300-by-300 pixels and the number (and dot) buttons are in a separate panel. Think carefully about the types of layout managers to use for each section of the frame. The accumulator label should begin with the text \"0\". For the accumulator label, I use the following code to make the font larger and right-aligned: label.setFont(new Font(\"Arial\", Font. PLAIN, 40)); label.set Horizontal Alignment(Swing Constants. RIGHT); Functional Requirements You also have a number of functional requirements. Whenever you press a key, you should append the label of that key onto the accumulator label. This allows you to type numbers. However, you should be aware of several things: Leading zeroes should be ignored. If your first click is the \"2\" button, the accumulator should read \"2\", not \"02\". You should only allow one dot to be entered. A second press of the button should have no observable effect If you press \"C\" button, the number should be cleared and be replaced with \"0\". It is up to you to figure out how to elegantly handle these cases.

Solution

1. At first Insert a <form> element within <body> tag.
2. Create a table using <table> .....</table> tag.
3. Insert two types of Input text and button within table data of table row using <tr><td>....</td></tr> tag.
4. Assign OnClick event for all the buttons having numbers and arithmetic operators.
5. Give blank value for Clear(C) button.
6. Use eval() function to evaluate the numbers on OnClick event of equal to sign button.

Full HTML code for a Simple HTML calculator

 In this lab, you will be creating a small program that looks like the keypad of a calculator. You should try to recreate the screenshot on the next page. For r

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site