From 31aa51cc66da1cf88b555f6a7a7f8cf761daaa89 Mon Sep 17 00:00:00 2001 From: LiviMcK <137836813+LiviMcK@users.noreply.github.com> Date: Wed, 4 Oct 2023 12:32:26 -0700 Subject: [PATCH] Lab 003 finished --- .idea/misc.xml | 2 +- src/GettingHotInHere.java | 17 ++++++++++++++--- src/MrRoboto.java | 10 +++++++--- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index cf9abe6..cbbff6a 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/GettingHotInHere.java b/src/GettingHotInHere.java index 7a5b209..b168299 100644 --- a/src/GettingHotInHere.java +++ b/src/GettingHotInHere.java @@ -2,13 +2,24 @@ public class GettingHotInHere { /** - * Teaching Mr. Roboto how to listen to us. * @param args Command line arguments [The source file path, The target file path, ...] + * @author Olivia McKittrick + * Teaching Mr. Roboto how to listen to us. **/ public static void main(String[] args) { - // The instantiation code for a Scanner instance. - Scanner scanner = new Scanner(System.in); + Scanner scanner = new Scanner(System.in); // The instantiation code for a Scanner instance. System.out.print("What is the temperature in °F: "); + int number = scanner.nextInt(); + + double celsius = (double) ((number - 32) * 5) / 9; + + System.out.printf("%.0f°F%n", (double) number); // Displays °F without a decimal + System.out.printf("%.6f°C%n", celsius); // Displays °C with a decimal + System.out.printf("%.0f°C%n", celsius); // Displays °C without a decimal + + double warmerCelsius = celsius + 2; + System.out.printf("If it were 2°C warmer it would be: %.6f°C%n", warmerCelsius); } } + diff --git a/src/MrRoboto.java b/src/MrRoboto.java index c576091..f7bb336 100644 --- a/src/MrRoboto.java +++ b/src/MrRoboto.java @@ -1,7 +1,8 @@ // Import the Scanner tool used for reading (All external packages/libraries/apis are imported similarly this) import java.util.Scanner; -public class MrRoboto { +public class +MrRoboto { /** * Teaching Mr. Roboto how to listen to us. * @param args Command line arguments [The source file path, The target file path, ...] @@ -10,10 +11,13 @@ public static void main(String[] args) { // The instantiation code for a Scanner instance. Scanner scanner = new Scanner(System.in); - // Concatenate the user response to this String. + String domo = "Domo arigato "; + System.out.print("My name is Mr. Roboto, are you Kilroy? "); - // Write your program here + String name = scanner.nextLine(); + System.out.print(domo + name); + } }