Computer Science Questions?

Computer Science Questions?




I need some help typing out these computer codes, for some reason I can't get the right message sent. Explaining how to write these codes out would be much appreciated.



Question #1: In the following code segment, x and y are Strings and the String y contains a simple HTML tag consisting of a left angle bracket, "<", a tag name (a String consisting of one or more letters only) and a right angle bracket, ">". Write code that stores the tag name in x. For example, if y is "<div>" then x should evaluate to "div".





Question #2: In the following code segment, d and e are Strings. The number of characters in d is an even number greater than zero. Write code that stores in e the String formed by switching the two halves of d. For example, if d is "pushdown", then e should evaluate to "downpush".


Update : my bad...



the language is Java.



Here's my attempted answer:



// Enter a value to test here:



String y = "animal";

String x;



// Enter your code here:



x=y.substring(1);



but when this code writes out, the first "<" is omitted but I can't figure out how to get rid of the sencond ">"





No Answers Posted Yet.