• Index » 
  • Community » 
  • Tech » 
  • Java experts, need help, help me with the pseuducode/Java code
Ayumiz
J-10 whore
+103|6745|Singapore
A virus detection program is used to detect the signature (i.e. identification code) of a known virus. The signature consists of three characters : d i e

Assuming that the variables have been declared and the three characters have been captured in the variables first_char, second_char and third_char respectively, write the Java code segment to detect the existence of the virus and display the appropriate message “Virus found” or “No virus found”.
Twist
Too old to be doing this sh*t
+103|6534|Little blue planet, milky way
So you build a string, and then you put char1, char2 and char3 into the string, you then compare the string to the value "die". If the comparison goes "I found nothing", then you put a "no " on the screen. Then you end by putting "Virus found" on the screen.
It's not that hard, it's basic programming, you dont need an expert for this, just read basic parsing and comparing values, and you'll be able to do this in about 5 minutes.
k0balt
Member
+1|6657|Cincinnati, OH
What you are asking for is a little vague. Can you give more specifics? Are you scanning through a single file, a group of files, or what?
Ayumiz
J-10 whore
+103|6745|Singapore
hmm its just some assignment though, testing us on the operator stuff. sry i am rather new to java.
chuyskywalker
Admin
+2,439|6859|"Frisco"

[pseudocode]

Code:

var total_chars = string_length(input)
for( var i = 0; i < total_chars; i++) {
  if( sub_string(i+0, i+3) == 'die' ) {
    return ERROR
  }
}
return SAFE
[/pseudocode]
Sgt.Scream.MDK
Member
+19|6774|Florida - America's Wang!

chuyskywalker wrote:

[pseudocode]

Code:

var total_chars = string_length(input)
for( var i = 0; i < total_chars; i++) {
  if( sub_string(i+0, i+3) == 'die' ) {
    return ERROR
  }
}
return SAFE
[/pseudocode]
You will run into a problem when i iterates to (total_chars - 3). When i loops to (total_chars - 3), substring will send an end index of (total_chars - 3) + 3, or total_chars. As strings are zero indexed, this would throw an IndexOutOfBounds Exception.

Hope this helps.
chuyskywalker
Admin
+2,439|6859|"Frisco"

PHP wouldn't care if you went out of bounds, it would simply return and empty string. php is kewl

I actually though of i < total_chars-3, but I was lazy and tired
Zimmer
Un Moderador
+1,688|6767|Scotland

chuyskywalker wrote:

PHP wouldn't care if you went out of bounds, it would simply return and empty string. php is kewl

I actually though of i < total_chars-3, but I was lazy and tired
Typical of Chuy.
Cerpin_Taxt
Member
+155|6214

chuyskywalker wrote:

PHP wouldn't care if you went out of bounds, it would simply return and empty string. php is kewl

I actually though of i < total_chars-3, but I was lazy and tired
Have you worked with the CakePHP framework? It's very similar to Ruby on Rails.
  • Index » 
  • Community » 
  • Tech » 
  • Java experts, need help, help me with the pseuducode/Java code

Board footer

Privacy Policy - © 2024 Jeff Minard