11 Replies - 937 Views - Last Post: 22 January 2012 - 05:19 PM Rate Topic: -----

Topic Sponsor:

#1 Techwizonline  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 26-October 11

Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 10:19 AM

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



Is This A Good Question/Topic? 0
  • +

Replies To: Pseudo-my loop does not stop when entering XXX for name

#2 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1169
  • View blog
  • Posts: 2,226
  • Joined: 30-May 10

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 10:29 AM

09 string QUIT = "XXX"

12 while not name = QUIT

How does it know the different between assignment and comparison?
Was This Post Helpful? 0
  • +
  • -

#3 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1812
  • View blog
  • Posts: 4,891
  • Joined: 27-December 05

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 10:39 AM

Also, why do you have two functions called housekeeping and how does the program choose between them?
Was This Post Helpful? 0
  • +
  • -

#4 ishkabible  Icon User is offline

  • spelling expert
  • member icon



Reputation: 1139
  • View blog
  • Posts: 4,775
  • Joined: 03-August 09

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 11:14 AM

I'm confused; how is this C or C++? is this pseudo code? if so how are you testing it?

This post has been edited by ishkabible: 22 January 2012 - 11:16 AM

Was This Post Helpful? 0
  • +
  • -

#5 Techwizonline  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 26-October 11

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 12:17 PM

Its is pseudocode. I have custom pseudocode interpreter that my professor creataed.
Was This Post Helpful? 0
  • +
  • -

#6 Techwizonline  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 26-October 11

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 12:31 PM

View Postishkabible, on 22 January 2012 - 11:14 AM, said:

I'm confused; how is this C or C++? is this pseudo code? if so how are you testing it?

Its is pseudocode. I have custom pseudocode interpreter that my professor creataed.

View PostSalem_c, on 22 January 2012 - 10:29 AM, said:

09 string QUIT = "XXX"

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.
Was This Post Helpful? 0
  • +
  • -

#7 ishkabible  Icon User is offline

  • spelling expert
  • member icon



Reputation: 1139
  • View blog
  • Posts: 4,775
  • Joined: 03-August 09

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 01:46 PM

how are we supposed to know what the issue is if we don't have documentation on the interpreter? at the very least we would need the source code or something.
Was This Post Helpful? 1
  • +
  • -

#8 r.stiltskin  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1812
  • View blog
  • Posts: 4,891
  • Joined: 27-December 05

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 01:54 PM

Since we don't have access to the documentation, we can't know what the "correct" syntax is for your while loop. However, it's reasonable to assume that if the = operator is used for assignment (as in your line 9), the same operator won't be used for comparison (as in your line 12).

Otherwise, how does the interpreter know whether you are doing an assignment or a comparison?
Was This Post Helpful? 0
  • +
  • -

#9 Techwizonline  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 26-October 11

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 03:04 PM

I just kept swinging at it and I hit a home run!!! Thanks for the reponses.
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

Was This Post Helpful? 0
  • +
  • -

#10 Techwizonline  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 13
  • Joined: 26-October 11

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 03:17 PM

View Postishkabible, on 22 January 2012 - 01:46 PM, said:

how are we supposed to know what the issue is if we don't have documentation on the interpreter? at the very least we would need the source code or something.

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.

View Postr.stiltskin, on 22 January 2012 - 01:54 PM, said:

Since we don't have access to the documentation, we can't know what the "correct" syntax is for your while loop. However, it's reasonable to assume that if the = operator is used for assignment (as in your line 9), the same operator won't be used for comparison (as in your line 12).

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.

View PostSalem_c, on 22 January 2012 - 10:29 AM, said:

09 string QUIT = "XXX"

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.
Was This Post Helpful? 0
  • +
  • -

#11 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon


Reputation: 7517
  • View blog
  • Posts: 28,881
  • Joined: 27-December 08

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 03:22 PM

This isn't C/C++, so I'm going to move this to Other Languages.
Was This Post Helpful? 0
  • +
  • -

#12 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 621
  • View blog
  • Posts: 1,038
  • Joined: 21-June 11

Re: Pseudo-my loop does not stop when entering XXX for name

Posted 22 January 2012 - 05:19 PM

View Postr.stiltskin, on 22 January 2012 - 09:54 PM, said:

Otherwise, how does the interpreter know whether you are doing an assignment or a comparison?


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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1