start Declarations string name num rate num currentSalary num newSalary string closing = "End of entries for this program!" string QUIT = "XXX" housekeeping() while not name = QUIT detailLoop() endwhile endOfJob() stop housekeeping() output "Please enter the employee's LAST name." input name output "Please enter rate increase." input rate detailLoop() return detailLoop() output "Please enter employee's CURRENT salary." input currentSalary set newSalary = currentSalary * (1 + rate) output name,"'s NEW SALARY is:" output newSalary housekeeping() return endOfJob() output closing return
11 Replies - 937 Views - Last Post: 22 January 2012 - 05:19 PM
#1
Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 10:19 AM
Replies To: Pseudo-my loop does not stop when entering XXX for name
#2
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 10:29 AM
12 while not name = QUIT
How does it know the different between assignment and comparison?
#3
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 10:39 AM
#4
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 11:14 AM
This post has been edited by ishkabible: 22 January 2012 - 11:16 AM
#5
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 12:17 PM
#6
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 12:31 PM
ishkabible, on 22 January 2012 - 11:14 AM, said:
Its is pseudocode. I have custom pseudocode interpreter that my professor creataed.
Salem_c, on 22 January 2012 - 10:29 AM, said:
12 while not name = QUIT
How does it know the different between assignment and comparison?
Im not quite sure what you are asking but QUIT has an assignment of "XXX" and my condition is set, so it stops when XXXis entered for the "name" input.
#7
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 01:46 PM
#8
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 01:54 PM
Otherwise, how does the interpreter know whether you are doing an assignment or a comparison?
#9
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 03:04 PM
start Declarations string name num rate num currentSalary num newSalary string closing = "End of entries for this program!" string quitEntry = "xxx" housekeeping() while not (name = quitEntry) detailLoop() endwhile endOfJob() stop housekeeping() output "Please enter the employee's FIRST name." input name return detailLoop() output "Please enter rate increase." input rate output "Please enter employee's CURRENT salary." input currentSalary set newSalary = currentSalary * (1 + rate) output name,"'s NEW SALARY is:" output newSalary, "US dollars" housekeeping() return endOfJob() output closing return
#10
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 03:17 PM
ishkabible, on 22 January 2012 - 01:46 PM, said:
Thanks for your input, but the interprter Im using was design by my professor for our programming logic and design class. It rides hand in hand with vb.net. Also here is the problem I was working on.
8. Draw the hierarchy chart and design the logic for a program
for the owner of Bits and Pieces Manufacturing Company,
who needs to calculate an employee’s projected salary
following a raise. Th e input is the name of the employee,
the employee’s current weekly salary, and the percentage
increase expressed as a decimal (for example, 0.04 for
a 4 percent raise). Design the program so that it runs
continuously for any number of employees using three
modules. Th e housekeeping module prompts the user for
the percent raise that will be applied to every employee,
and prompts for the fi rst employee’s name. Th e detail loop
executes continuously until the user enters “XXX” for the
employee’s name. Th e detail loop gets the employee’s weekly
salary, applies the raise, produces the result, and prompts
for the next employee name. Th e end-of-job module, which
executes after the user enters the sentinel value for the name,
displays a message that indicates the program is complete.
r.stiltskin, on 22 January 2012 - 01:54 PM, said:
Otherwise, how does the interpreter know whether you are doing an assignment or a comparison?
Thanks for your input, but the interprter Im using was design by my professor for our programming logic and design class. It rides hand in hand with vb.net. Also here is the problem I was working on.
8. Draw the hierarchy chart and design the logic for a program
for the owner of Bits and Pieces Manufacturing Company,
who needs to calculate an employee’s projected salary
following a raise. Th e input is the name of the employee,
the employee’s current weekly salary, and the percentage
increase expressed as a decimal (for example, 0.04 for
a 4 percent raise). Design the program so that it runs
continuously for any number of employees using three
modules. Th e housekeeping module prompts the user for
the percent raise that will be applied to every employee,
and prompts for the fi rst employee’s name. Th e detail loop
executes continuously until the user enters “XXX” for the
employee’s name. Th e detail loop gets the employee’s weekly
salary, applies the raise, produces the result, and prompts
for the next employee name. Th e end-of-job module, which
executes after the user enters the sentinel value for the name,
displays a message that indicates the program is complete.
Salem_c, on 22 January 2012 - 10:29 AM, said:
12 while not name = QUIT
How does it know the different between assignment and comparison?
Thanks for your input, but the interprter Im using was design by my professor for our programming logic and design class. It rides hand in hand with vb.net. Also here is the problem I was working on.
8. Draw the hierarchy chart and design the logic for a program
for the owner of Bits and Pieces Manufacturing Company,
who needs to calculate an employee’s projected salary
following a raise. Th e input is the name of the employee,
the employee’s current weekly salary, and the percentage
increase expressed as a decimal (for example, 0.04 for
a 4 percent raise). Design the program so that it runs
continuously for any number of employees using three
modules. Th e housekeeping module prompts the user for
the percent raise that will be applied to every employee,
and prompts for the fi rst employee’s name. Th e detail loop
executes continuously until the user enters “XXX” for the
employee’s name. Th e detail loop gets the employee’s weekly
salary, applies the raise, produces the result, and prompts
for the next employee name. Th e end-of-job module, which
executes after the user enters the sentinel value for the name,
displays a message that indicates the program is complete.
#11
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 03:22 PM
#12
Re: Pseudo-my loop does not stop when entering XXX for name
Posted 22 January 2012 - 05:19 PM
r.stiltskin, on 22 January 2012 - 09:54 PM, said:
Easy: A `=` encountered in a statement context, it is an assignment. If it is encountered in an expression context, it is a comparison. That's how most (all?) Basics do it. As long as assignment statements aren't expressions, that approach fine.
Of course that means that you can't use comparisons as statements of their own, but in languages that allow that, doing so is (almost?) always a bug anyway.
|
|

New Topic/Question
Reply



MultiQuote






|