LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Develop a VI to encode or decode words using a secret code.

Question:

Develop a VI to encode or decode words using a secret code. To encode a word in this code, first separate the word into two substrings – one with the first half of the original word, and one containing the second half. If there is an odd number of letters in the word, then split it so that the first substring has one more letter than the second one.
Create the encoded word by concatenating the first half of the word onto the end of the second half of the word, inserting the second letter of the original word in between these two halves. For example, the word “gravity” would be encoded as “ityrgrav” and the word “master” would be encoded as “teramas.”
Place a string control on the front panel and a Boolean switch allowing the user to select whether the input is to be decoded or encoded. Display the output on a string indicator.
words using a secret code. To encode a word in this code, first separate the word into two substrings – one with the first half of the original word, and one containing the second half. If there is an odd number of letters in the word, then split it so that the first substring has one more letter than the second one.
Create the encoded word by concatenating the first half of the word onto the end of the second half of the word, inserting the second letter of the original word in between these two halves. For example, the word “gravity” would be encoded as “ityrgrav” and the word “master” would be encoded as “teramas.”
Place a string control on the front panel and a Boolean switch allowing the user to select whether the input is to be decoded or encoded. Display the output on a string indicator.

 

 

Someone please help 😞 im so lost

0 Kudos
Message 1 of 13
(3,069 Views)

This sounds like a homework problem. We're not here to do your homework for you; maybe you can show us what you have so far and any specific questions you have.

0 Kudos
Message 2 of 13
(3,066 Views)

Talk to your classmates.  Talk to your instructor.  Take the first step (split the word into two sub-strings) and figure out how to do that.  Ask yourself:

  • What information do you need to know before splitting the word in half?
  • How would you get this information?
  • Once you have it, and the original string, what do you want to do?
  • Find the LabVIEW functions that you need to do the above steps.  Put them on a Block Diagram, wire them up, put in a String Control at the input, and a pair of String Indicators at the output.  Now test your code by putting, say, "Master" in the Input and seeing what comes out.  Use other examples until you are sure your code is correct.
  • Once you've mastered the First Step, start on the Second Step.  Then the Third.  Pretty soon, you've finished, and you have (I hope) learned something.

Bob Schor

 

P.S. -- from having taught Programming, there is only one way to learn Programming, and that is by Writing Programs.

0 Kudos
Message 3 of 13
(3,061 Views)

That was a fun little exercise.  So where are you stuck?  String manipulations can get interesting, but do give the String palette a good look over.  There are some really useful functions in there such as String Length, Search/Split String, String Subset, and Concatenate String.  Along with those functions, you will probably want a Divide and a Round To +Inf.  Use the same functions to decode.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 13
(3,019 Views)

Unfortunately, the "code" is now no longer secret. 😄

0 Kudos
Message 5 of 13
(2,991 Views)

nice try this is your instructor

0 Kudos
Message 6 of 13
(2,642 Views)

@unljerry wrote:

nice try this is your instructor


To be fair, I think that coming to the forum to ask questions about the homework wasn't a bad idea; it's only when the student asks for answers without explanation, that's where it goes bad.  We try to guide the student towards a solution by dropping hints and asking questions that lead them to a conclusion of their own.  Think of us as the "tutor collective".  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 7 of 13
(2,607 Views)

Technically, (s)he didn't ask questions. Except "someone please help" perhaps, but that's just one question at most!

 

Everything else is more a statement that a question.

 

That's an almost guarantee to not get an answer: making statements, not asking questions.

0 Kudos
Message 8 of 13
(2,570 Views)

unljerry

you do realize that you are responding to a thread that is over a year old. Those students are long gone. 

0 Kudos
Message 9 of 13
(2,564 Views)

@jamiva wrote:

unljerry

you do realize that you are responding to a thread that is over a year old. Those students are long gone. 


Nobody helped, so he might be stuck in that class until someone does.

0 Kudos
Message 10 of 13
(2,555 Views)