

InterviewSolution
1. |
Solve : Algorithms Am I on the right track?? |
Answer» I really want to understand this was wondering if I have the right idea as far as answering the questions so far. It seems to be so basic ~ for an example, I think if I input 55 the output would be both outputs: output "your grade is" 55 and output "you did OK", I know X represents the integer right? What language is this? An conceptual teaching language, maybe? I am not sure if it is a language, I am PRETTY new at this. So can someone tell me this..when would endif output "how did you do?" pop up? I mean if there is no room for error, or no error output, would that even be relevant? And is my answer of there being 4 nesting correct? Or is only one nest since all the info comes in between input X and endif? I am sorry, I am trying to understand. Thanks for your input.As I understand, you want to find where a scalper is in a range of values, then print a message for that range only. NORMALLY the variable is non the left and the constant t is on the right. Here is a similar solution. We make a block and break out of the block when we are in a range. Let invest a thing called "block" so we don't need the else if thing. Code: [Select]begin block if X < 50 { output "you fail" break } if X < 70 { output "your grade is" X output "you did OK" break } if X < 85 { output "your grade is" X output "you did well" break } if X < 100 { output "your grade is" X output "you did great" break } output "your grade is " X output "please report to the dean's office" end block output "end of report" I believe this is what you intend, but it is maybe not self-evident, But that is how programmers do things. It might be easier to understand if you made and object that tests for range and outputs a message. That is great, you have really assisted me in understanding this on a much better level. Thank you so much! Glad to help. Your problem can benefit from a CASE or SWITCH structure. Or you could create your own special function or procedure. You may like to read this: http://en.wikipedia.org/wiki/Switch_statement In some applications, maybe a network database, reducing the block to minimal code may be a critical issue to improve response time. Quote Optimized switchThis can be an interlinings area of study if you need to work with SQL or similar things.Geek, I don't think you realise what is going on here. I tried to give a hint, but you didn't take it up. I'll try to make it simple. 1. The OP, webdev57, is not seeking help to write some code. He or she is seeking help with a school or college assignment. 2. The assignment is to read a program, written in a pseudocode and answer questions about how it would work. 3. How it would work, that is, if it were a real programming language. 4. The pseudocode contains structures and logic found in programming languages. 5. That is what I meant about teaching language but it evidently passed you by. 6. The above is obvious from the format of the original post, in my opinion. Thank you Salmon Trout, Did not mean to do his homework for him. Quote from: Geek-9pm on September 03, 2011, 12:07:42 AM Thank you Salmon Trout, I think you were OK, he asked enough questions to show that he was thinking the project through, and he seemed to want confirmation that he was on the right track, as his title says. I just thought you were wasting your time re writing the code though. Helpful though that seems to have been. Quote from: Salmon Trout on September 03, 2011, 12:11:31 AM ...His code was hard to read. It was redundant and would never do inside of a loop. I just had to re write it. Quote from: Geek-9pm on September 03, 2011, 01:02:21 AM His code was hard to read. It was redundant and would never do inside of a loop. I just had to re write it. It wasn't "his" code; I am pretty sure of that, and I don't see why it shouldn't work within a loop. Why do you say that? Since it is in a yet-to-be-determined language, we cannot make assumptions like that. The code listed asks the user to input a number and then using conditional logic, do various things depending on the value of that number. The code is written in a kind of generic "does-not-actually-exist" programming language. The object of the exercise seems to be to evaluate the student's ability to read source code and deduce what it does, independent of any particular language implementation. Salmon Trout. You are very perceptive. I made the mistake of thinking he wrote it. I did not say it would not work. I was guessing that a compiler would not optimize it. i think this language must be visual basic right? ..oh how really miss studying its been 3 years since i last practice my programming skills fortunately i joined such forum thanks guys for some refresment |
|