Java, 1819T3

Pod Activity: Java Spelunking

Put your answers in a plain text document. If you don't have a text editor Atom is great for this purpose. Get it.

Problem 1: Make a variable quack and intialize it with integer value 1. What does quack *= 2 do to quack? Repeat this a bunch of times. How many times does it take for something to do drastically wrong?

Research Problem Read about Two's complement in Wikipedia. Can you explain specifically what happened in terms of that? What is type overflow? Write a short explanation.

Problem 2: What is 10/7? What happened?

Go here and search for the String class.

Making a string is easy. Watch this.

jshell> String s = "caterwaul";
s ==> "caterwaul"

jshell> 

Look in the Method Summary for ways to do this. The . works just like it did in Python.

Problem 3:Tell how to get the characters to print individually.

Problem 4:Demonstrate the endsWith method in a JShell session.

Problem 4:Show how to tell how, if given two strings, one precedes the other asciicographically? How about alphabetically?

Problem 5: Use the format method to format a line in an HTML table such as this.

<tr><td>Musial</td><td>Stan</td><td>475</td></tr>

Problem 6: How do you tell is a string contains only white space?

Problem 7: what is the quickest way to do this?

***************************************************************

Java Math

The math functions in Java have the standard names you know and love from Python, JavaScript, C, C++, or Ruby.

Search for the Math class in the docs. It's in java.lang.Math

Problem 1: Compute this $$\sqrt{1 + \cos(45^\circ)}. $$ Watch out.

Problem 2: Compute this $$\log_2{1000}. $$

Problem 3: A triangle has sides of length 6 and 7 and these subtend an angle of \(105^\circ\). Find the length of the thid side

Problem 4: Compute this $$e^{.692}. $$