diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..172df7b 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..9770967 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,21 @@ Explore the behavior of the `System.out.printf` function when displaying values ### **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. +Kelten's note +Main error messages I got +1. 8:2 java: reached end of file while parsing +2. java: class, interface, enum, or record expected +3. use --enable-preview to enable unnamed classes +4. Exception in thread "main" java.util.IllegalFormatConversionException: f != java.lang.Integer +at java.base/java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4515) +at java.base/java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:3079) +at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:3027) +at java.base/java.util.Formatter.format(Formatter.java:2791) +at java.base/java.io.PrintStream.implFormat(PrintStream.java:1367) +at java.base/java.io.PrintStream.format(PrintStream.java:1346) +at java.base/java.io.PrintStream.printf(PrintStream.java:1245) +at PF.main(java.java:4)** + ### **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.. @@ -65,6 +80,9 @@ Enter a total number of seconds: 5000 **Hint:** * The modulus operator is the remainder operator and will simplify the calculation. +Editors note here +I looked up online to find a way to calculate seconds to Hours Minutes and remaining Seconds cause I got tired of trying to do it myself + ### Submission Follow these steps for submission: 1. Create a Feature01 branch of your code if you haven't already. diff --git a/src/Printf.java b/src/Printf.java new file mode 100644 index 0000000..97dfacf --- /dev/null +++ b/src/Printf.java @@ -0,0 +1,11 @@ +public class Printf { + public static void main(String[] args) { + int Number1 = 16; + System.out.printf("1. %f%n", Number1); + double Number2 = 6.27; + System.out.printf("2.%d%n", Number2); + int Number3 = 16; + System.out.printf("3. %d %f%n", Number3); + + } + } diff --git a/src/Seconds.java b/src/Seconds.java new file mode 100644 index 0000000..13bafc7 --- /dev/null +++ b/src/Seconds.java @@ -0,0 +1,17 @@ +import java.util.Scanner; +public class Seconds { + public static void main(String[] args) { + //Input + System.out.print("Enter the number of seconds: "); + //Reads the Input + Scanner scanner = new Scanner(System.in); + int Time = scanner.nextInt(); + //Calculates the Input + int Hours = Time / 3600; + int Minutes = (Time % 3600) / 60; + int Seconds = Time % 60; + //The Output + System.out.printf("%d Seconds = %d Hours, %d Minutes, and %d Seconds%n", + Time, Hours, Minutes, Seconds); + } +} \ No newline at end of file diff --git a/src/TempConvert.java b/src/TempConvert.java new file mode 100644 index 0000000..26cf4dc --- /dev/null +++ b/src/TempConvert.java @@ -0,0 +1,18 @@ +import java.util.Scanner; +class TempConvert { + public static void main(String[] args) { + //Input + System.out.print("Enter temperature: "); + + //Takes the Input and reads it as a double output + Scanner scanner = new Scanner(System.in); + double celsius = scanner.nextDouble(); + + //Calucates the result + double fahrenheit = celsius * 9 / 5 + 32; + + //Prints the output + System.out.printf("%.1f Celsius is equal to %.1f Fahrenheit%n", celsius, fahrenheit); + + } +} \ No newline at end of file