diff --git a/.idea/misc.xml b/.idea/misc.xml index 639900d..cbbff6a 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..338dfb9 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,5 @@ Follow these steps for submission: 3. Push it to your Remote/origin branch (i.e., GitHub: Feature01 -> origin/Feature01). 4. Issue a Pull request to my instructor repo. 5. **Make sure to COPY the Pull request URL and submit it for the lab/assignment in Canvas.** + + diff --git a/src/Assignment failure.png b/src/Assignment failure.png new file mode 100644 index 0000000..7436017 Binary files /dev/null and b/src/Assignment failure.png differ diff --git a/src/TemperatureConvert.java b/src/TemperatureConvert.java new file mode 100644 index 0000000..55f6fae --- /dev/null +++ b/src/TemperatureConvert.java @@ -0,0 +1,31 @@ +import java.util.Scanner; +public class TemperatureConvert { + + public static void main(String[] args) { + double F; + double C; + Scanner in = new Scanner(System.in); + System.out.print("Input temperature in Celsius: "); + C = in.nextDouble(); + System.out.println("Your input " + C + "C"); + F = (C * 9 / 5) + 32; + System.out.println(C + "C" + " = " + F + "F"); + System.out.println(F + "F" + " = " + C + "C"); + in.close(); + + /* Just for my own practice, I'm putting the code down in reverse. + double F; + double C; + Scanner in = new Scanner(System.in); + System.out.print("Input temperature in Fahrenheit: "); + F = in.nextDouble(); + System.out.println("You input " + F + "F"); + C = (F - 32) * 5/9; + System.out.println(C + "C" + " = " + F + "F"); + System.out.println(F + "F" + " = " + C + "C"); + in.close(); + */ + + } +} + diff --git a/src/TimeConverter.java b/src/TimeConverter.java new file mode 100644 index 0000000..68562b5 --- /dev/null +++ b/src/TimeConverter.java @@ -0,0 +1,19 @@ +import java.util.Scanner; + +public class TimeConverter { + public static void main(String[] args) { + int hour, minute, second, seconds; + final int minPerHr = 60 * 60; // 3600 + Scanner in = new Scanner(System.in); + System.out.print("Input number of seconds: "); + seconds = in.nextInt(); + second = seconds % 60 % 60; + minute = (seconds % minPerHr) / 60; + hour = seconds / 60 / 60; + System.out.print(hour + " hours "); + System.out.print(minute + " minutes "); + System.out.println(second + " seconds."); + System.out.printf("%d seconds = %d hours, %d minutes, and %d seconds.", seconds, hour, minute, second); + in.close(); + } +} \ No newline at end of file