diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..69ace3f 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/Java-Lab-003.iml b/Java-Lab-003.iml index b46c0dd..e1006ff 100644 --- a/Java-Lab-003.iml +++ b/Java-Lab-003.iml @@ -5,6 +5,7 @@ + \ No newline at end of file diff --git a/README.md b/README.md index cdcf86f..6958058 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,14 @@ Explore the behavior of the `System.out.printf` function when displaying values 2. Display a `double` using `%d`. 3. Try using two format specifiers but provide only one value. + + ### **Instructions:** For each of the issues above, screenshot and add the error images to this repo named **error01.png, error02.png, and error003.png** or simply edit this README.md and use markdown to list the error messages received. ### **Note:** Your answers to this exercise should be added using Markdown into the project's `README.md` file so that they get committed with the project's code.. - +- I added three screen shots of errors made to my two converter programs. --- ## Part 2: Celsius to Fahrenheit Converter diff --git a/error01.png b/error01.png new file mode 100644 index 0000000..1b05eea Binary files /dev/null and b/error01.png differ diff --git a/error02.png b/error02.png new file mode 100644 index 0000000..2d47323 Binary files /dev/null and b/error02.png differ diff --git a/error03.png b/error03.png new file mode 100644 index 0000000..8e90da4 Binary files /dev/null and b/error03.png differ diff --git a/src/CelsiusToFahrenheit.java b/src/CelsiusToFahrenheit.java new file mode 100644 index 0000000..bdee3fe --- /dev/null +++ b/src/CelsiusToFahrenheit.java @@ -0,0 +1,21 @@ +import java.util.Scanner; + +public class CelsiusToFahrenheit { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + //prompt for input + System.out.println("Enter Celsius: "); + + //read double from keyboard + double celsius = scanner.nextDouble(); + + //calculate + double fahrenheit = celsius * 9 / 5 + 32; + + //format to one decimal + System.out.printf("%.1f Celsius = %.1f Fahrenheit%n", celsius, fahrenheit); + + } +} diff --git a/src/SecondstoTimeConverter.java b/src/SecondstoTimeConverter.java new file mode 100644 index 0000000..009b239 --- /dev/null +++ b/src/SecondstoTimeConverter.java @@ -0,0 +1,27 @@ +import java.util.Scanner; + + +public class SecondstoTimeConverter { + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + //Prompt for input + System.out.println("Enter number of seconds: "); + + //read int from keyboard + int totalSeconds = scanner.nextInt(); + + //calculate using modulus + int hours = totalSeconds / 3600; + int minutes = (totalSeconds % 3600) / 60; + int remainingSeconds = totalSeconds % 60; + + //use printf to format + System.out.printf("%d seconds = %d hours, %d minutes, %d seconds%n", + totalSeconds, hours, minutes, remainingSeconds); + + + + } +}