RE: What do you guys think, pseudo code attempt

  • From: "Joseph Lee" <joseph.lee22590@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Mon, 28 Jun 2010 15:02:43 -0700

Hi,
Seems nice now. At least you've got the basics of how to write psudo code
before you program it. Keep up your effort.
As for the output part, a nice trick is to put the calculation as part of
the output, such as:
Output should be, "The commission rate is " << the calculation (sales times
commission rate) << "per whatever."
In C++:
cout << "The commission rate is " << sales*rate << " per month." << endl;
And that's it. Hope this helps...
Cheers,
Joseph

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes
Sent: Monday, June 28, 2010 2:55 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: Re: What do you guys think, pseudo code attempt

Here is another attempt, hopefully I am getting the concept of an algorithm.
Let me know.
The following contains pseudo code, as well as algorithm and two desk
checks.

Output:  displays the commission on screen.
Input: the salesperson's sales and commission rate.
Processing: When the program is compiled, the user should be able to
multiply someone's current sales rate by the commission rate, which is
currently 10%. If the commission rate changes, just substitute 10% with the
new rate when entering the calculations. This should give the user a sales
person's commission rate after the person's sales rate is entered.

Algorithm:
1. Ask user to enter a  sales and commission rate.
2. Store data into two separate variables, one for commission rate and one
for sales rate.
3. Multiply the data in the variables.
4. Output the result back to the user.

Desk-check 1:
2000*.10 = 200. Correct.
Desk-check 2:
5000*.06 = 300. Both Desk-checks Succeeded.


On Jun 28, 2010, at 4:00 PM, Joseph Lee wrote:

> Hi,
> As for putting in values, it's really up to you to decide. In my case, I
> tend to create variables right before a user needs to enter that variable;
> sometimes I do what I've wrote on the list - just create a list of
variables
> in the beginning and tell the computer what to expect (as you have seen).
> Also, a repeating advice: you might want to comment your code using one
line
> comment indicator (//) - especially after you put in your variables to
> really make sure you do know what a given variable is.
> As for VS2008, not sure about System Access. You might want to contact
Mike
> at Serotek if they have any solutions for using SA with VS2008 (I use JFW
> with it).
> Hope this helps...
> Cheers,
> Joseph
> 
> -----Original Message-----
> From: programmingblind-bounce@xxxxxxxxxxxxx
> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes
> Sent: Monday, June 28, 2010 12:48 PM
> To: programmingblind@xxxxxxxxxxxxx
> Subject: Re: What do you guys think, pseudo code attempt
> 
> Thanks for the help, Joseph. But how do you know what to put in what
field?
> In other words, can you get a list of functions, values, etc, for C++ on
the
> internet or in visual studio or something?
> As a previous poster on list wrote in and said he was going to v s 2008, I
> think I'm going to go back to 2008. 2010 keeps giving me these code is out
> of date errors. That, and the text editor is not accessible at all using
> system acess. I think 2008 was accessible so will go back to that.
> Jes
> 
> On Jun 28, 2010, at 3:18 PM, Joseph Lee wrote:
> 
>> Hi,
>> The code seems nice here. Only thing I'd like to add is just one more
>> variable to store the remaining balance. So, if we translate this into
> C++,
>> it becomes (only the main algorithm is done; hope someone can provide
> other
>> versions in other languages...
>> // The four variables (for now, we'll use integers):
>> int current_balance; // The checking account balance at the start of the
>> month.
>> int deposit; // The deposit amount.
>> int withdrawl; // The amount withdrawn.
>> int remaining_balance; // The balance at the end of the month.
>> cout << "Please type your current balance:" << endl;
>> cin >> current_balance;
>> cout << "How much did you deposit during the month:" << endl;
>> cin >> deposit;
>> cout << "How much did you withdraw:" << endl;
>> cin >> withdrawl;
>> // Now, add the deposit to the current balance and subtract withdrawl.
>> // Note: Be sure to check that the money left after this operation is not
> a
>> negative number!
>> // For sake of previews, I'll provide two versions: a regular calculation
>> and a function.
>> // Version A: Regular one...
>> remaining_balance = current_balance + deposit - withdrawl;
>> if (remaining_balance < 0)
>> cout << "Oops, you've used more than your account..." << endl;
>> else
>> cout << "You have $" << remaining_balance << "remaining." << endl;
>> // Version B: Using the calculation as a function...
>> // In other words, we'll provide a shortcut, or a name of a function,
> which
>> will perform the above code.
>> // This version would be a preview for you:
>> int calculate_balance(int cb, int d, int w)
>> {
>> int r; // The remaining balance.
>> R = cb+d-w;
>> Return (r);}
>> // Now, the main part...
>> // After the user enters all the info...
>> R = calculate_balance(current_balance, deposit, withdrawl);
>> // After that, the "if" statement will come up and check for errors.
>> The reason I tried both versions is to illustrate that the problem can be
>> solved using so many ways. In addition to the two methods described here,
> we
>> can come up with literally hundreds of ways of doing this, including
>> creating more complicated functions that will also check the error for
you
>> within a function, creating an actual check object (this is called a
> class)
>> and so on.
>> Hope this helps...
>> Cheers,
>> Joseph P.S. As always, please come up with your own code... (mostly for
>> academic integrity...).
>> 
>> -----Original Message-----
>> From: programmingblind-bounce@xxxxxxxxxxxxx
>> [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Jes
>> Sent: Monday, June 28, 2010 11:17 AM
>> To: programmingblind@xxxxxxxxxxxxx
>> Subject: What do you guys think, pseudo code attempt
>> 
>> Hi all,
>> Here is an attempt  at filling out an IPO chart, and putting in some
> pseudo
>> code within the processing items. Let me know your thoughts. The
following
>> also contains two desk-checks.
>> 
>> Output: display user's checking account balance at the end of the month.
>> Input: Three pieces of info: His checking account balance at the start of
>> the month, money deposited into his account during the month, and  money
>> withdrawn from his account during the month.
>> 
>> Processing:
>> Algorithm:
>> 
>> First main function, Print message asking user for each piece of
>> information. Used to help computer accomplish the user's goal.
>> Create three separate variables:
>> A variable for storing beginning checking account balance.
>> A  variable for storing deposits.
>> A  variable to store withdrawal.
>> each variable should be created after user inputs data, and should be in
> the
>> same order as the messages which are displayed.
>> on the screen for each piece of information.
>> 
>> Finally, process all variables to get new account balance, and display
the
>> information on the screen to the user.
>> 
>> First desk-check
>> checking account balance at the beginning of the month:
>> 2000
>> money deposited during the month:
>> 775
>> money withdrawn during the month:
>> 1200
>> Result: New balance = 1575.
>> 
>> second desk-check:
>> checking account balance at the beginning of the month:
>> 500
>> money deposited during the month:
>> 100
>> money withdrawn during the month:
>> 610
>> Result: -10
>> Something is wrong with the second desk-check. What is it?
>> 
>> __________
>> View the list's information and change your settings at 
>> //www.freelists.org/list/programmingblind
>> 
>> No virus found in this incoming message.
>> Checked by AVG - www.avg.com 
>> Version: 8.5.439 / Virus Database: 271.1.1/2967 - Release Date: 06/28/10
>> 06:37:00
>> 
>> __________
>> View the list's information and change your settings at 
>> //www.freelists.org/list/programmingblind
>> 
> 
> __________
> View the list's information and change your settings at 
> //www.freelists.org/list/programmingblind
> 
> No virus found in this incoming message.
> Checked by AVG - www.avg.com 
> Version: 8.5.439 / Virus Database: 271.1.1/2967 - Release Date: 06/28/10
> 06:37:00
> 
> __________
> View the list's information and change your settings at 
> //www.freelists.org/list/programmingblind
> 

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

No virus found in this incoming message.
Checked by AVG - www.avg.com 
Version: 8.5.439 / Virus Database: 271.1.1/2967 - Release Date: 06/28/10
06:37:00

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: