Pseudocode Assignment For the problem statement below, you must write the Pseudo
ID: 3751411 • Letter: P
Question
Pseudocode Assignment
For the problem statement below, you must write the Pseudocode for each part of the solution.
Problem Statement:
Create a application that acts as a simple calculator. Create buttons for 0-9 and a text field that displays the concatenation of the current digits as they are clicked. Add buttons for operators “+”, “-“, “*”, and “/”. Add a final button for “=” that calculates the computed value with the value entered in the text field. For instance, clicking buttons 7, +, 8, = should display 15.
Break the problem down and write the pseudocode:
Break the problem statement into parts to fully understand what is expected as input, output and processes in your code. Write down all the variables you will need from the problem statement. Once you have broken down the problem, start writing your pseudocode.
Writing the pseudocode may take a while and several iterations to fully get the solution complete. Walk through the problem and your pseudocode as if the program is running.
Now make sure that your code is the best it can be. Check your formatting, comments, and make sure your output is correct and communicates what is happening in your code.
Explanation / Answer
Pseudocode for the calculater program:
num_first as double
num_second as double
answer as double
operator as string
create textbox
create button 0 {
when clicked follow below command
if textbox.text = 0 then textbox.text=0
else textbox.text = textbox.text append 0 }
create button 1
{
when clicked follow below command
if textbox.text = 0 then textbox.text=1
else textbox.text = textbox.text append 1 }
create button 2
{
when clicked follow below command
if textbox.text = 0 then textbox.text=2
else textbox.text = textbox.text append 2 }
create button 3
{
when clicked follow below command
if textbox.text = 0 then textbox.text=3
else textbox.text = textbox.text append 3 }
create button 4
{
when clicked follow below command
if textbox.text = 0 then textbox.text=4
else textbox.text = textbox.text append 4}
create button 5
{
when clicked follow below command
if textbox.text = 0 then textbox.text=5
else textbox.text = textbox.text append 5}
create button 6
{
when clicked follow below command
if textbox.text = 0 then textbox.text=6
else textbox.text = textbox.text append 6 }
create button 7
{
when clicked follow below command
if textbox.text = 0 then textbox.text=7
else textbox.text = textbox.text append 7 }
create button 8
{
when clicked follow below command
if textbox.text = 0 then textbox.text=8
else textbox.text = textbox.text append 8 }
create button 9
{
when clicked follow below command
if textbox.text = 0 then textbox.text=9
else textbox.text = textbox.text append 9 }
create button + {
when clicked follow below command
num_first = textbox.text
textbox.text= ""
operator = +
}
create button -
{
when clicked follow below command
num_first = textbox.text
textbox.text= ""
operator = -
}
create button *
{
when clicked follow below command
num_first = textbox.text
textbox.text= ""
operator = *
}
create button /
{
when clicked follow below command
num_first = textbox.text
textbox.text= ""
operator = /
}
create button = {
// After pressing this button below query should execute
num_second = textbox.text
if operator = + then
answer = num_first + num_second
textbox.text = answer
else if operator = - then
answer = num_first - num_second
textbox.text = answer
else if operator = * then
answer = num_first * num_second
textbox.text = answer
else if operator = / then
answer = num_first / num_second
textbox.text = answer
end if
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.