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/error1.png b/error1.png new file mode 100644 index 0000000..f1b17ea Binary files /dev/null and b/error1.png differ diff --git a/error2.png b/error2.png new file mode 100644 index 0000000..806256d Binary files /dev/null and b/error2.png differ diff --git a/error3.png b/error3.png new file mode 100644 index 0000000..5dd5143 Binary files /dev/null and b/error3.png differ diff --git a/src/Format.java b/src/Format.java new file mode 100644 index 0000000..8c7e76b --- /dev/null +++ b/src/Format.java @@ -0,0 +1,16 @@ +public class Format { + + public static void main(String[] args) { + + int Value = 24; + System.out.printf("%f", Value); + + double doubleValue = 6.42; + System.out.printf("%d", doubleValue); + + int Value1 = 42; + System.out.printf("%d %s", Value1); + + + } +} diff --git a/src/TempConvert.java b/src/TempConvert.java new file mode 100644 index 0000000..8132b67 --- /dev/null +++ b/src/TempConvert.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class TempConvert { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter a temperature in Celsius: "); + double celsius = scanner.nextDouble(); + + double fahrenheit = celsius * 9 / 5 + 32; + System.out.printf("%.1f C = %.1f F%n", celsius, fahrenheit); + + scanner.close(); + + } +} diff --git a/src/TimeConvert.java b/src/TimeConvert.java new file mode 100644 index 0000000..28f94cd --- /dev/null +++ b/src/TimeConvert.java @@ -0,0 +1,19 @@ +import java.util.Scanner; + +public class TimeConvert { + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.print("Enter the total number of seconds: "); + int totalSeconds = scanner.nextInt(); + + int hours = totalSeconds / 3600; + int minutes = (totalSeconds % 3600) / 60; + int seconds = totalSeconds % 60; + + System.out.printf("%d seconds = %d hours, %d minutes, and %d seconds%n", totalSeconds, hours, minutes, seconds); + + scanner.close(); + } +} +