Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Java-Lab-003.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ For each of the issues above, screenshot and add the error images to this repo n
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..

---
# Answers:
1. Argument type 'int' does not match the type of the format specifier '%f'
2. Argument type 'double' does not match the type of the format specifier '%d'
3. Too few arguments for format string (found: 1, expected: 2)

## Part 2: Celsius to Fahrenheit Converter

Expand All @@ -48,8 +52,7 @@ Enter a temperature in Celsius: 24

## Part 3: Seconds to Time Converter

**Objective:**
Write a Java program that converts a total number of seconds to hours, minutes, and seconds.
**Objective:**Write a Java program that converts a total number of seconds to hours, minutes, and seconds.

**Steps:**
1. Prompt the user for input.
Expand Down
12 changes: 12 additions & 0 deletions src/TempConvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import java.util.Scanner;

public class TempConvert {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter temperature in Celsius: ");
double celsius = scanner.nextDouble();

double fahrenheit = (celsius * 9/5) + 32;
System.out.printf("Temperature in Fahrenheit: %.1f\n", fahrenheit);
}
}
15 changes: 15 additions & 0 deletions src/TimeConvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import java.util.Scanner;

public class TimeConvert {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("# of seconds: ");
int total = scanner.nextInt();

int hours = total / 3600;
int minutes = (total % 3600) / 60;
int seconds = total % 60;

System.out.printf("%d seconds = %d hours, %d minutes, and %d seconds.\n", total, hours, minutes, seconds);
}
}