Since I love case-statements, I decided to make the most out of them during the rock, paper, scissors program.
The gist of the pseudo-code I wrote up for the program is below.
/*
CIS 217 Midterm
Melanie Draves
04 Mar 2012
Pseudo-code
Narrative dsecription
Program will simulate a game of Rock-Paper-Scissors. To do this, the program will
generate a number at random from 1-3, which is to be the computer's selection.
Once user selects their choice, the answer and winner will be revealed.
Then the user can choose to start another game or exit the program.
Selection
1 rock
2 paper
3 scissors
Variables
Inputs
userchoice int
Outputs
compchoice int (the random num)
Temps
outcome int
Pseudo-code
1 compchoice = generate random number
2 userchoice = call GetUserChoice();
3 outcome = call DetOutcome(compchoice, userchoice)
4 call DispWinner(outcome)
HALT
-----
method DetOutcome(int lcompchoice, luserchoice)
returns: int
loutcome int
switch(lcompchoice)
case 0:
if (luserchoice < 1)
then TIE //loutcome = 1
elseif (luserchoice > 1)
then lcompchoice = WINNER //loutcome = 2
else lcompchoice = LOSER //loutcome = 3
case 1:
if (luserchoice = 1)
then TIE //loutcome = 4
elseif (luserchoice > 1)
then lcompchoice = LOSER //loutcome = 5
else lcompchoice = WINNER //loutcome = 6
case 2:
if (luserchoice > 1)
then TIE //loutcome = 7
elseif (luserchoice < 1)
then lcompchoice = LOSER //loutcome = 8
else lcompchoice = WINNER //loutcome = 9
default:
return(loutcome)
-----
method DispWinner(int loutcome)
return: void
msg1 string "TIE!, select Go to play again"
msg2 string "YOU WIN!, select Go to play again"
msg3 string "I WIN!, select Go to play again"
show compchoiceLabel
show userchoiceLabel
switch(loutcome)
case 1:
display "Your Choice = Rock ; My Choice = Rock"
display msg1
case 2:
display "Your Choice = Scissors; My Choice = Rock"
display msg3
case 3:
display "Your Choice = Paper ; My Choice = Rock"
display msg2
case 4:
display "Your Choice = Paper ; My Choice = Paper"
display msg1
case 5:
display "Your Choice = Scissors ; My Choice = Paper"
display msg2
case 6:
display "Your Choice = Rock ; My Choice = Paper"
display msg3
case 7:
display "Your Choice = Scissors ; My Choice = Scissors"
display msg1
case 8:
display "Your Choice = Rock ; My Choice = Scissors"
display msg2
case 9:
display "Your Choice = Paper ; My Choice = Scissors"
display msg3
default:
return
*/
Pseudo-code for Joe's Automotive program
/*
pseudo-code
Program: Joe's Automotive
Name: Melanie Draves
Date: Feb 26 2012
Narrative Description:
Program calculate and display a customer's total charges incurred for a visit to an automotive establishment.
Calculations for regular services are based on the following schedule:
Inspection 15.00
Lube job 18.00
Tire rotation 20.00
Oil change 26.00
Radiator flush 30.00
Trnsmissn flush 80.00
Muffler replace 100.00
nonroutine svc 20.00 * Hours worked
Calculations to be made by the following methods:
(value-returning)
totoillube = OilLubeChrgs Method for oil change and/or lube job
totflush = FlushChrgs Method for radiator flush and/or transmission flush
totmisc = MiscChrgs Method for inspection, muffler replacement, and/or tire rotation
totother = OtherChrgs Method for services/labor (if applicable)
tottax = 0.06 * amt of parts Method for sales tax charged on parts
totfees = TotalChrgs Method for total charges
(void methods) called when the user click 'Clear' button
ClrOilLube Method for clearing oil change and lube job check boxes
ClrFlushes Method for clearing radiator and transmission flushes check boxes
ClrMisc Method for clearing inspection, muffler replacement, tire rotation check boxes
ClrOther Method for clearing parts and labor text boxes
ClrFees Method for clearing 'summary' labels
Variables:
Inputs
oil, lube - bool
radflsh, tranflsh
inspect, muffreplace, tirerotate
amtparts - decimal = 0
hrslabor - int = 0
Outputs
totother - decimal
amtparts - decimal
tottax - decimal
totfees - decimal
Temps
totoilube - decimal
totflush - decimal
totmisc - decimal
pseudo-code:
MAIN
init vars
calc tot charges
totoillube = OilLubeChrgs(oil, lube)
totflush = FlushChrgs(radflsh, tranflsh)
totmisc = MiscChrgs(inspect, muffreplace, tirerotate)
totother = OtherChrgs(amtparts, hrslabor)
tottax = 0.06 * amtparts
totfees = TotalChrgs(totoillube, totflush, totmisc, totother, tottax)
display totals
disp totother
disp amtparts
disp tottax
disp totfees
clear form
ClrOilLube
ClrFlushes
ClrMisc
ClrOther
ClrFees
HALT
-----
method OilLubeChrgs(loil, llube)
ret: ltotoillube
*/
Before I program solutions, I like to write pseudo-code to plan out the steps that I intend to take!
The following is my plan for the Hospital Charges program
/*
Pseudo-code
Program: Hospital Charges
Name: Melanie Draves
Date: Feb 26 2012
Narrative Description:
Program will calculate the total cost for a patient's hospital stay. Calculation variables include:
number of days of hospital stay
medication charges incurred
surgical charges incurred
lab charges incurred
physical rehabilitation charges incurred
Program will calculate totals using the following methods:
CalcStayCharges = $350 * number of days of hospital stay
CalcMiscCharges = medication charges incurred + surgical charges incurred + lab charges incurred + medical rehabilitation charges incurred
CalcTotalCharges = CalcStayCharges + CalcMiscCharges
Variables:
Inputs
numdays - int
medchrg - real
srgchrg - real
labchrg - real
rehbchrg - real
Outputs
totcost - real
Temps
staychrg - real
miscchrg - real
Pseudo-code:
MAIN
get inputs
calc tot's
staychrg = CalcStayCharges(numdays)
miscchrg = CalcMiscCharges(medchrg, srgchrg, labchrg, rehbchrg)
totcost = CalcTotalCharges()
display tot's
HALT
-----
method CalcTotalCharges(real lstaychrg, real lmiscchrg)
ret ltotcost - real
ltotcost = lstaychrg + lmiscchrg
return(ltotcost)
-----
method CalcMiscCharges(real lmedchrg, real lsrgchrg, real llabchrg, real lrehbchrg)
ret: lmiscchrg - real
lmiscchrg = lmedchrg + lsrgchrg + llabchrg + lrehbchrg
return(lmiscchrg)
-----
method CalcStayCharges(int lnumdays)
ret: lstaychrg - real
lstaychrg = 350 * lnumdays
return(lstaychrg)
*/v
I've recently migrated over to 2010 -- this is to say that I've recently started working at a company with an enterprise level 2010 SharePoint instance.
As I was doing to customer requirement - content type-architecture-alignment and testing last week, I noticed that there are various SharePoint site columns that can't be modified and / or removed from (even) a custom list once they've been added.
I did quick internet search and wasn't able to find anything riveting.
Anyone know what the scoop is on this?
Info we're given:
- A table of workshop information (title, length (# of days), and registration fee of various workshops)
- A table of workshop locations and their corresponding lodging fees per day
The requirements consist of:
- Displaying the form where the user can select which workshop they want to attend and the site of the workshop
- Then display the estimated cost of the selected workshop and location
So what to do first?....
As a general rule, I start by writing some pseudo-code. I like to plan prior to coding, to avoid jeopardizing the success of my program as much as possible.
This time though, I’m going to start by building my input form:

Once the input form is designed and ready, I'll need to do the following:
-
Create my variables (inputs, temps, and outputs)
-
Get inputs &
-
Store variables for final calculations
-
Calculate totals
-
Display outputs in the form
Step #1
Not a whole lot happens until the inputting user clicks the button to calculate, so once that happens, the following can create and initialize my variables:
Steps #2 & 3
Since I wanted to make use of the new cool decision structures we’ve learned this section, I decided to leverage my personal favorite: the switch statement!

And of course, to get the location input as well:

So then all we have left to do is to calculate the total fees and output them to the form.
Step # 5 & # 6

and that’s about it as far as the mechanics go…, let’s check out the form when the program is actually run:

Hooray! : )
Starting Out with Visual C# 2010 (2nd edition) -- Here is a overly-simplified analysis of the foundational concepts presented in the book