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>
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ Explore the behavior of the `System.out.printf` function when displaying values
### **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.

Kelten's note
Main error messages I got
1. 8:2 java: reached end of file while parsing
2. java: class, interface, enum, or record expected
3. use --enable-preview to enable unnamed classes
4. Exception in thread "main" java.util.IllegalFormatConversionException: f != java.lang.Integer
at java.base/java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4515)
at java.base/java.util.Formatter$FormatSpecifier.printFloat(Formatter.java:3079)
at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:3027)
at java.base/java.util.Formatter.format(Formatter.java:2791)
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 PF.main(java.java:4)**

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

Expand Down Expand Up @@ -65,6 +80,9 @@ Enter a total number of seconds: 5000
**Hint:**
* The modulus operator is the remainder operator and will simplify the calculation.

Editors note here
I looked up online to find a way to calculate seconds to Hours Minutes and remaining Seconds cause I got tired of trying to do it myself

### Submission
Follow these steps for submission:
1. Create a Feature01 branch of your code if you haven't already.
Expand Down
11 changes: 11 additions & 0 deletions src/Printf.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
public class Printf {
public static void main(String[] args) {
int Number1 = 16;
System.out.printf("1. %f%n", Number1);
double Number2 = 6.27;
System.out.printf("2.%d%n", Number2);
int Number3 = 16;
System.out.printf("3. %d %f%n", Number3);

}
}
17 changes: 17 additions & 0 deletions src/Seconds.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import java.util.Scanner;
public class Seconds {
public static void main(String[] args) {
//Input
System.out.print("Enter the number of seconds: ");
//Reads the Input
Scanner scanner = new Scanner(System.in);
int Time = scanner.nextInt();
//Calculates the Input
int Hours = Time / 3600;
int Minutes = (Time % 3600) / 60;
int Seconds = Time % 60;
//The Output
System.out.printf("%d Seconds = %d Hours, %d Minutes, and %d Seconds%n",
Time, Hours, Minutes, Seconds);
}
}
18 changes: 18 additions & 0 deletions src/TempConvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import java.util.Scanner;
class TempConvert {
public static void main(String[] args) {
//Input
System.out.print("Enter temperature: ");

//Takes the Input and reads it as a double output
Scanner scanner = new Scanner(System.in);
double celsius = scanner.nextDouble();

//Calucates the result
double fahrenheit = celsius * 9 / 5 + 32;

//Prints the output
System.out.printf("%.1f Celsius is equal to %.1f Fahrenheit%n", celsius, fahrenheit);

}
}