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..992f526 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,36 @@ 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. +### **First Error;** +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 Format.main(Format.java:5) + +### **Second error;** +Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double +at java.base/java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4515) +at java.base/java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:3066) +at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:3021) +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 Format.main(Format.java:5) + +### **Third error;** +Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%f' +at java.base/java.util.Formatter.format(Formatter.java:2790) +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 Format.main(Format.java:5) + ### **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.. diff --git a/src/.gitkeep b/src/.gitkeep index 8b13789..e69de29 100644 --- a/src/.gitkeep +++ b/src/.gitkeep @@ -1 +0,0 @@ - diff --git a/src/Error-1.png b/src/Error-1.png new file mode 100644 index 0000000..4113cd1 Binary files /dev/null and b/src/Error-1.png differ diff --git a/src/Error-2.png b/src/Error-2.png new file mode 100644 index 0000000..d6a41c6 Binary files /dev/null and b/src/Error-2.png differ diff --git a/src/Error-3.png b/src/Error-3.png new file mode 100644 index 0000000..1a5f7c9 Binary files /dev/null and b/src/Error-3.png differ diff --git a/src/Format.java b/src/Format.java new file mode 100644 index 0000000..b819eb5 --- /dev/null +++ b/src/Format.java @@ -0,0 +1,8 @@ +public class Format { + + public static void main(String[] args) { + int a = 10; + System.out.printf("print %d %f", a); + } + } + diff --git a/src/TempConvert.java b/src/TempConvert.java new file mode 100644 index 0000000..b16bcec --- /dev/null +++ b/src/TempConvert.java @@ -0,0 +1,18 @@ +import java.util.Scanner; +public class TempConvert { + public static void main(String[] args) { + System.out.println("Please Enter The Temperature in Celsius: "); + Scanner scanner = new Scanner(System.in); + double celsius = scanner.nextDouble(); + double fahrenheit = celsius * 9/5 + 32; + + System.out.println(celsius + " C = " + (fahrenheit) + " F"); + scanner.close(); + + } +} +//creating scanner and object to read inputs +//prompt for user to input +//read what user typed +//calculate the temp from C to F +//close scanner \ No newline at end of file diff --git a/src/TimeConvert.java b/src/TimeConvert.java new file mode 100644 index 0000000..3401b3e --- /dev/null +++ b/src/TimeConvert.java @@ -0,0 +1,20 @@ +import java.util.Scanner; +public class TimeConvert { + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + System.out.println("Please Enter Total Number of Seconds: "); + + int seconds; + seconds = in.nextInt(); + + int convertMinutes = seconds/60; + int convertHours = convertMinutes/60; + int convertSeconds = seconds - convertMinutes*60; + + System.out.println(convertHours+ " Hours, "+ convertMinutes%60 +" Minutes, and " +convertSeconds +" Seconds"); + } +} +//Asking for user input +//reading the input +//calculate the result +//print result \ No newline at end of file