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
04 Mar 2012
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.
compchoice int (the random num)
1 compchoice = generate random number
2 userchoice = call GetUserChoice();
3 outcome = call DetOutcome(compchoice, userchoice)
4 call DispWinner(outcome)
method DetOutcome(int lcompchoice, luserchoice)
if (luserchoice < 1)
then TIE //loutcome = 1
elseif (luserchoice > 1)
then lcompchoice = WINNER //loutcome = 2
else lcompchoice = LOSER //loutcome = 3
if (luserchoice = 1)
then TIE //loutcome = 4
elseif (luserchoice > 1)
then lcompchoice = LOSER //loutcome = 5
else lcompchoice = WINNER //loutcome = 6
if (luserchoice > 1)
then TIE //loutcome = 7
elseif (luserchoice < 1)
then lcompchoice = LOSER //loutcome = 8
else lcompchoice = WINNER //loutcome = 9
method DispWinner(int loutcome)
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"
display "Your Choice = Rock ; My Choice = Rock"
display "Your Choice = Scissors; My Choice = Rock"
display "Your Choice = Paper ; My Choice = Rock"
display "Your Choice = Paper ; My Choice = Paper"
display "Your Choice = Scissors ; My Choice = Paper"
display "Your Choice = Rock ; My Choice = Paper"
display "Your Choice = Scissors ; My Choice = Scissors"
display "Your Choice = Rock ; My Choice = Scissors"
display "Your Choice = Paper ; My Choice = Scissors"
Pseudo-code for Joe's Automotive program
Program: Joe's Automotive
Name: Melanie Draves
Date: Feb 26 2012
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:
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:
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
oil, lube - bool
inspect, muffreplace, tirerotate
amtparts - decimal = 0
hrslabor - int = 0
totother - decimal
amtparts - decimal
tottax - decimal
totfees - decimal
totoilube - decimal
totflush - decimal
totmisc - decimal
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)
method OilLubeChrgs(loil, llube)
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
Program: Hospital Charges
Name: Melanie Draves
Date: Feb 26 2012
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
numdays - int
medchrg - real
srgchrg - real
labchrg - real
rehbchrg - real
totcost - real
staychrg - real
miscchrg - real
staychrg = CalcStayCharges(numdays)
miscchrg = CalcMiscCharges(medchrg, srgchrg, labchrg, rehbchrg)
totcost = CalcTotalCharges()
method CalcTotalCharges(real lstaychrg, real lmiscchrg)
ret ltotcost - real
ltotcost = lstaychrg + lmiscchrg
method CalcMiscCharges(real lmedchrg, real lsrgchrg, real llabchrg, real lrehbchrg)
ret: lmiscchrg - real
lmiscchrg = lmedchrg + lsrgchrg + llabchrg + lrehbchrg
method CalcStayCharges(int lnumdays)
ret: lstaychrg - real
lstaychrg = 350 * lnumdays
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
Display outputs in the form
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