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>
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@ Explore the behavior of the `System.out.printf` function when displaying values
2. Display a `double` using `%d`.
3. Try using two format specifiers but provide only one value.



### **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.

### **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..

- I added three screen shots of errors made to my two converter programs.
---

## Part 2: Celsius to Fahrenheit Converter
Expand Down
Binary file added error01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added error02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added error03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions src/CelsiusToFahrenheit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.util.Scanner;

public class CelsiusToFahrenheit {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

//prompt for input
System.out.println("Enter Celsius: ");

//read double from keyboard
double celsius = scanner.nextDouble();

//calculate
double fahrenheit = celsius * 9 / 5 + 32;

//format to one decimal
System.out.printf("%.1f Celsius = %.1f Fahrenheit%n", celsius, fahrenheit);

}
}
27 changes: 27 additions & 0 deletions src/SecondstoTimeConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import java.util.Scanner;


public class SecondstoTimeConverter {

public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

//Prompt for input
System.out.println("Enter number of seconds: ");

//read int from keyboard
int totalSeconds = scanner.nextInt();

//calculate using modulus
int hours = totalSeconds / 3600;
int minutes = (totalSeconds % 3600) / 60;
int remainingSeconds = totalSeconds % 60;

//use printf to format
System.out.printf("%d seconds = %d hours, %d minutes, %d seconds%n",
totalSeconds, hours, minutes, remainingSeconds);



}
}