DOC PREVIEW
UNF COP 2551 - Study Notes

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Pseudo-code for Program 2/** Be sure to add Javadoc entries** Every method should have an @param and an @return* Javadoc comments MUST precede every method in Java*/// Could put the following logic in a getInputs static method in class Main. But for now, let’s keep this inline.Prompt for user’s name (first and last). // two separate prompts, one for first name one for last.Read in string values for firstName and lastName.Set count to 0Prompt for user’s classification as an integer ranging from 1 to 5 (frosh to grad student)Loop while (count < 3)If classification not equal 1 through 5Increment countElseIf classification = 1Set classification to FreshmanElse if classification is a 2Set classification to SophomoreEtc.Break (leave while loop)End ifIf count < 3Prompt user with same messageRead in user’s value for classificationElseDisplay Sorry, Charlie. Get a life!Break// go to end program (TBD)EndifEndLoop// here we will call a method in Main.Set integerCount to 1Loop while integerCount < 3Prompt user to input three integersRead in three integers and assign them to int1, int2, and int3.Set char Result = Call average (pass int1, int2, int3 and integerCount)// average will compute the average in one of three ways depending on integerCount.// letter grade is returned as a characterIf integerCount is 1, set char gradeOut1 to Result If integerCount is 2, set char gradeOut2 to ResultIf integerCount is 3, set char gradeOut3 to ResultIncrement integerCountendLoop// when get to here, we have the three letter grades, gradeOut 1, 2, and 3// we also have a valid classification and name// Output display routineSkip a couple of blank lines Set int integerCounter to 0Loop while integerCounter <3If integerCount is 1, Print out Last Name and First Name and his/her classification followed by “earned a“ gradeOut1 “computed using an if…else statement” If integerCount is 2, Print out Last Name and First Name and his/her classification followed by “earned a“ gradeOut2 “computed using a nested-if construct”) If integerCount is 3, Print out Last Name and First Name and his/her classification followed by “earned a“ gradeOut 3 “computed using a Switch construct”) Increment integerCounterEnd Loop// Check out counter values to ensure we don’t try to loop one more time than necessary……Print out “That’s all folks!” // ensure apostrophe prints outTerminate program//Method to average three integers: This is a second method in public class Main that will physically // follow the public static void main method./** Be sure to add Javadoc entries** Every method should have an @param and an @return* Javadoc comments MUST precede every method in Java*/public static char average (inta, intb, intc, icount)set sum and average to 0.Add inta, intb, intc giving sumDivide sum by 3 giving average.If icount is 1Calculate letterGrade using simple if statementsIf icounr is 2Calculate letterGrade using nested if statementsIf icount is 3Calculate letterGrade using a Switch statementreturn the letterGrade as a char // End average


View Full Document

UNF COP 2551 - Study Notes

Download Study Notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Study Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?