'F' → Fullscreen
public class Program { public static void main(String[] args) { // --- Basic String Concatenation --- System.out.println("Part 1: Basic String and Number Concatenation"); System.out.println("Hello" + " world!"); System.out.println("Today's number is " + 7); System.out.println("Pi is approximately " + 3.14159); System.out.println("------------------------------------");// }}
public class Program { public static void main(String[] args) { // --- Basic String Concatenation --- System.out.println("Part 1: Basic String and Number Concatenation"); System.out.println("Hello" + " world!"); System.out.println("Today's number is " + 7); System.out.println("Pi is approximately " + 3.14159); System.out.println("------------------------------------");
// --- Combining Strings with Arithmetic Expressions --- System.out.println("Part 2: Combining with Math Expressions"); System.out.println("5 squared is " + (5 * 5)); System.out.println("The area of a circle with a radius of 4 is " + (4 * 4 * 3.14)); System.out.println("If I have 25 marbles and my friend gives me 15 more, I have a total of " + (25 + 15) + " marbles."); System.out.println("------------------------------------");// }}
public class Program { public static void main(String[] args) { // --- Basic String Concatenation --- System.out.println("Part 1: Basic String and Number Concatenation"); System.out.println("Hello" + " world!"); System.out.println("Today's number is " + 7); System.out.println("Pi is approximately " + 3.14159); System.out.println("------------------------------------");
// --- Combining Strings with Arithmetic Expressions --- System.out.println("Part 2: Combining with Math Expressions"); System.out.println("5 squared is " + (5 * 5)); System.out.println("The area of a circle with a radius of 4 is " + (4 * 4 * 3.14)); System.out.println("If I have 25 marbles and my friend gives me 15 more, I have a total of " + (25 + 15) + " marbles."); System.out.println("------------------------------------");
// --- Building a Sentence with Multiple Parts --- System.out.println("Part 3: Building a Full Sentence"); System.out.println("The current year is " + 2024 + ". The next year will be " + (2024 + 1) + "."); System.out.println("The temperature in my city is " + 72 + " degrees Fahrenheit."); System.out.println("A dozen is 12. Two dozen is " + (12 + 12) + "."); System.out.println("------------------------------------");// }}
public class Program { public static void main(String[] args) { // --- Basic String Concatenation --- System.out.println("Part 1: Basic String and Number Concatenation"); System.out.println("Hello" + " world!"); System.out.println("Today's number is " + 7); System.out.println("Pi is approximately " + 3.14159); System.out.println("------------------------------------");
// --- Combining Strings with Arithmetic Expressions --- System.out.println("Part 2: Combining with Math Expressions"); System.out.println("5 squared is " + (5 * 5)); System.out.println("The area of a circle with a radius of 4 is " + (4 * 4 * 3.14)); System.out.println("If I have 25 marbles and my friend gives me 15 more, I have a total of " + (25 + 15) + " marbles."); System.out.println("------------------------------------");
// --- Building a Sentence with Multiple Parts --- System.out.println("Part 3: Building a Full Sentence"); System.out.println("The current year is " + 2024 + ". The next year will be " + (2024 + 1) + "."); System.out.println("The temperature in my city is " + 72 + " degrees Fahrenheit."); System.out.println("A dozen is 12. Two dozen is " + (12 + 12) + "."); System.out.println("------------------------------------");
// --- Converting an Expression to a String First --- System.out.println("Part 4: Converting Expressions to Strings"); System.out.println("Here is a number " + (10 + 20)); // The parentheses force the addition first. System.out.println("But what if we did not have parentheses?"); System.out.println("If you put a string in front, it all becomes a string: " + 10 + 20); System.out.println("To fix this, use parentheses: " + (10 + 20));// }}
Your program output should something similar to the sample output below.
Part 1: Basic String and Number ConcatenationHello world!Today's number is 7Pi is approximately 3.14159------------------------------------Part 2: Combining with Math Expressions5 squared is 25The area of a circle with a radius of 4 is 50.24If I have 25 marbles and my friend gives me 15 more, I have a total of 40 marbles.------------------------------------Part 3: Building a Full SentenceThe current year is 2024. The next year will be 2025.The temperature in my city is 72 degrees Fahrenheit.A dozen is 12. Two dozen is 24.------------------------------------Part 4: Converting Expressions to StringsHere is a number 30But what if we did not have parentheses?If you type 10 + 20, the result will be a number: 30But if you put a string in front, it all becomes a string: 1020To fix this, use parentheses: 30
You may write your reflection answers as comments at the bottom of your code.
Submit your activity and reflection answers to the appropriate dropbox.