Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you please tell me what the errors are in this debug? // This program create

ID: 3860199 • Letter: C

Question

Can you please tell me what the errors are in this debug?

// This program creates a screen with a textbox and a button.
// When the user clicks the button, a label displays the result
// which is 10% of the number in the textbox
start
Declarations
Screen screen1
Button calcButton
Textbox usersEntry
Label result
screen1.setSize(200, 200)
calcButton.setText("Click to calculate 10% tax")
screen1.add(usersEntry)
screen1.add(calcButton)
stop

calculateTax()
Declarations
Label result
num tax
num RATE = 0.10
string answer
tax = usersEntry.getText() * RATE
answer = "The tax is ", tax
screen1.add(result)
return   

Explanation / Answer

You have not specified whihc programming language it is in . But by looking at the code, these are mistakes I found

1. You need to add result Label only once , initally when you create the screen. Otherwise , every time you click and calculate button, the label will be added.

2. You need to link the button with the function calculateTax() i.e. set up buttton's click event to call calculateTax() function.

3. In calculateTax() method, (I hope you already have access to the result label), set the answer to result label's text

Hope it helps.

Modified code should look something like below. Please add the code to link the buttton's click with calculateTax().

// This program creates a screen with a textbox and a button.
// When the user clicks the button, a label displays the result
// which is 10% of the number in the textbox
start
Declarations
Screen screen1
Button calcButton
Textbox usersEntry
Label result
screen1.setSize(200, 200)
calcButton.setText("Click to calculate 10% tax")
screen1.add(usersEntry)
screen1.add(calcButton)
screen1.add(result)

//*************** need to link calcButton to call calculateTax() ***************

stop
calculateTax()
Declarations
num tax
num RATE = 0.10
string answer
tax = usersEntry.getText() * RATE
answer = "The tax is ", tax
result.setText(answer)
return   

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote