I learned this technique from a TA in college, it is called "using indicator variable" and the name pretty much says the essence of this technique.
the program below is coding bat exercise.i solved it
the question itself:
Return the sum of the numbers in the array, except ignore
sections of numbers starting with a 6 and extending to
the next 7 (every 6 will be followed by at least one 7).
Return 0 for no numbers.
Question:
1.is there other technique to avoid using "indicator variable" trick?
2.I suspect it is not "design patterns " that explains these little tricks. but I need to know all those little things.
what is the part of software development that describes these tricks/techniques to newbies? how is it called? 3. what books are there that give you list of those little techniques? or maybe tutorials? anything would be great! recommendations?
P.S. i would not be able to solve this problem another way , if i did not know indicator variable thing! So i want to know other ways of solving this problem!
Hi, i have been solving codingbat exercises in java.
I consider myself a beginner and quite often i have to write each iteration with pen/paper to understand what i am doing, especially when using loops and recursion
as a wanna-be-efficient programmer, i suspect it is possible to automate this process,i.e. write some applet or function that you can give parameters and it will go through array/string and highlight every comparison/check step-by-step.
is there any educational applet/program that you can give parameters like array to go through, operation to do and it will highlight and show slow /fast speed visualization?
Question:
1. do you know software/applet that does it?
2. if not, this could be another idea - write my own project for myself/educational purposes; in this case, how can i do this?
actual question:
Given two strings, return true if either of the strings appears at the very end of the other string, ignoring upper/lower case differences (in other words, the computation should not be "case sensitive"). Note: str.toLowerCase() returns the lowercase version of a string.
===============================================
i m 90% sure this code can be simplified, but i don't know other logic or way of thinking about this simple exercise
can someone help me refactor it and make it smaller?
what i don't get is why it never goes to * part of code
for example if the string given is "xHix" , it only deletes last x , but the first x is still there ,
and it gives wrong answer "xHi", but it should delete the first "x"
the code below generates a question on number multiplication (inside applet)
e.g. - "what is 5 times 6"
the user enters answer and clicks button - if he is right, "very good " is displayed and a new string (question) is shown
or "try again" is shown and he has to answer it again
this is a WORKING CODE, i only need to make generate_question() and check_answer() methods to get called from paint() method
I DON'T HAVE paint() coded yet - i m asking you guys how to do it?
paint() should look like this - paint(Graphics g) {......}
-------------------------------------
Java how to program chapter 6, 4ed, ex 6.31