From e870d1cd6f8ec52ac216c8d4405cd149f3341c95 Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Thu, 14 Sep 2023 12:44:52 -0700 Subject: [PATCH] Followed detailed instructions to create scanner and add temperature conversion. --- src/GettingHotInHere.java | 20 +++++++++++++++++++- src/MrRoboto.java | 15 ++++++++++----- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/GettingHotInHere.java b/src/GettingHotInHere.java index 7a5b209..adccedc 100644 --- a/src/GettingHotInHere.java +++ b/src/GettingHotInHere.java @@ -3,12 +3,30 @@ public class GettingHotInHere { /** * Teaching Mr. Roboto how to listen to us. + * * @param args Command line arguments [The source file path, The target file path, ...] **/ public static void main(String[] args) { // The instantiation code for a Scanner instance. Scanner scanner = new Scanner(System.in); System.out.print("What is the temperature in °F: "); - int number = scanner.nextInt(); + + // fTemp = the temperature in Fahrenheit as an int. + int fTemp = scanner.nextInt(); + System.out.println(fTemp+"°F"); + + //equasion for converting Fahrenheit to Celsius as a floating point number. + double yCel = (fTemp-32.0)*(5.0/9); + + // print double of Celsius temperature. + System.out.printf("%.6f°C%n",yCel); + + //print int of Celsius temperature. + System.out.println((int)yCel+ "°C"); + + //print Celsius temperature + 2 degress as a floating point number. + String plusTwo = "If it were 2°C warmer it would be: "; + System.out.print(plusTwo); + System.out.printf("%.6f°C%n",yCel); } } diff --git a/src/MrRoboto.java b/src/MrRoboto.java index c576091..6fb9aaa 100644 --- a/src/MrRoboto.java +++ b/src/MrRoboto.java @@ -9,11 +9,16 @@ public class MrRoboto { 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? "); + String myName = scanner.nextLine(); // Write your program here + + +String ddomo = ("My name is Mr. Roboto, are you Kilroy? no, I'm stan "); + +String ari = ("Domo arigato no, I'm stan"); + + System.out.println(ddomo+"\n"+ari); + System.out.println(myName); } -} +} \ No newline at end of file