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>
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,45 @@ 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:**
### **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:**
### **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..

---
--- My Error code
### 1.
C:\Users\rigel\.jdks\openjdk-21.0.2\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\lib\idea_rt.jar=59747:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\rigel\IdeaProjects\Java-Lab-003\out\production\Java-Lab-003 TempConvert
Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%f'
at java.base/java.util.Formatter.format(Formatter.java:2790)
at java.base/java.io.PrintStream.implFormat(PrintStream.java:1367)
at java.base/java.io.PrintStream.format(PrintStream.java:1346)
at java.base/java.io.PrintStream.printf(PrintStream.java:1245)
at TempConvert.main(TempConvert.java:9)

Process finished with exit code 1
### 2.
C:\Users\rigel\.jdks\openjdk-21.0.2\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\lib\idea_rt.jar=52558:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\rigel\IdeaProjects\Java-Lab-003\out\production\Java-Lab-003 TempConvert
Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%d'
at java.base/java.util.Formatter.format(Formatter.java:2790)
at java.base/java.io.PrintStream.implFormat(PrintStream.java:1367)
at java.base/java.io.PrintStream.format(PrintStream.java:1346)
at java.base/java.io.PrintStream.printf(PrintStream.java:1245)
at TempConvert.main(TempConvert.java:8)

Process finished with exit code 1

### 3.
C:\Users\rigel\.jdks\openjdk-21.0.2\bin\java.exe "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\lib\idea_rt.jar=52651:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2023.3.2\bin" -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -classpath C:\Users\rigel\IdeaProjects\Java-Lab-003\out\production\Java-Lab-003 TempConvert
Exception in thread "main" java.util.MissingFormatArgumentException: Format specifier '%f'
at java.base/java.util.Formatter.format(Formatter.java:2790)
at java.base/java.io.PrintStream.implFormat(PrintStream.java:1367)
at java.base/java.io.PrintStream.format(PrintStream.java:1346)
at java.base/java.io.PrintStream.printf(PrintStream.java:1245)
at TempConvert.main(TempConvert.java:6)

Process finished with exit code 1


## Part 2: Celsius to Fahrenheit Converter

Expand Down
16 changes: 16 additions & 0 deletions src/SecondsTimeConverter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import java.util.Scanner;
// This one just prints because I'm not that good with popup windows yet
public class SecondsTimeConverter {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of seconds: ");
int seconds = scanner.nextInt();
int remainingSeconds = seconds % 60;
int minutes = (seconds / 60) % 60;
int hours = seconds / 3600;

System.out.println("The number of hours passed is: " + hours);
System.out.println("The number of minutes passed is: " + minutes);
System.out.println("The number of seconds left is: " + remainingSeconds);
}
}
33 changes: 33 additions & 0 deletions src/TempConvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import java.util.Scanner;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class TempConvert {
public static void main(String[] args) {

Scanner s= new Scanner(System.in);

System.out.print("Please enter the temperature in Celsius ");
String input = s.nextLine();
double Temp = Integer.parseInt(input); // User input
double TempF = Temp * 9/5 + 32;

// Create the frame (window)
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Set frame title
frame.setTitle("Temperature in F");

// Add a label with some text to the frame
frame.add(new JLabel("The Temperature is "+TempF));

// Always on Top
frame.setAlwaysOnTop(true);
// Set frame size
frame.setSize(500, 500);

// Make the frame visible
frame.setVisible(true);
}
}