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/src/TempConvert.java b/src/TempConvert.java new file mode 100644 index 0000000..20ff10a --- /dev/null +++ b/src/TempConvert.java @@ -0,0 +1,16 @@ +import java.util.Scanner; + +public class TempConvert { + public static void main(String[] args) { + double conversion; + Scanner in = new Scanner(System.in); + System.out.print("Type a temperature in Celsius and I will calculate it into Fahrenheit: "); + conversion = in.nextInt(); + System.out.printf(conversion + " Celsius is "+"%.1f Fahrenheit", (conversion*1.8+32)); + } +} +//Prompt the user for input. +//Read a double value from the keyboard. +//Calculate the result using the formula: F = C × 9/5 + 32. +//Format the output to one decimal place. +//Test the program by entering a temperature in Celsius. diff --git a/src/TimeConvert.java b/src/TimeConvert.java new file mode 100644 index 0000000..a27e4f3 --- /dev/null +++ b/src/TimeConvert.java @@ -0,0 +1,19 @@ +import java.util.Scanner; + +public class TimeConvert { + public static void main(String[] args) { + int seconds; + Scanner in = new Scanner(System.in); + System.out.print("Enter an amount of seconds: "); + seconds = in.nextInt(); + int convMinutes = seconds/60; + int convHours = convMinutes/60; + int convSeconds = seconds - convMinutes*60; + System.out.println(convHours+" hours, "+ convMinutes%60 +" minutes, and " +convSeconds +" seconds"); + } +} + +//Prompt the user for input. +//Read an integer from the keyboard (total number of seconds). +//Calculate the result using the modulus operator. +//Use printf to display the output in the format: "5000 seconds = 1 hours, 23 minutes, and 20 seconds". \ No newline at end of file diff --git a/src/error01.png b/src/error01.png new file mode 100644 index 0000000..407225b Binary files /dev/null and b/src/error01.png differ diff --git a/src/error02.png b/src/error02.png new file mode 100644 index 0000000..94250ff Binary files /dev/null and b/src/error02.png differ diff --git a/src/error03.png b/src/error03.png new file mode 100644 index 0000000..b594c16 Binary files /dev/null and b/src/error03.png differ