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>
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,36 @@ 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.

### **First Error;**
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 Format.main(Format.java:5)

### **Second error;**
Exception in thread "main" java.util.IllegalFormatConversionException: d != java.lang.Double
at java.base/java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4515)
at java.base/java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:3066)
at java.base/java.util.Formatter$FormatSpecifier.print(Formatter.java:3021)
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 Format.main(Format.java:5)

### **Third error;**
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 Format.main(Format.java:5)

### **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
1 change: 0 additions & 1 deletion src/.gitkeep
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Binary file added src/Error-1.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 src/Error-2.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 src/Error-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions src/Format.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
public class Format {

public static void main(String[] args) {
int a = 10;
System.out.printf("print %d %f", a);
}
}

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;
public class TempConvert {
public static void main(String[] args) {
System.out.println("Please Enter The Temperature in Celsius: ");
Scanner scanner = new Scanner(System.in);
double celsius = scanner.nextDouble();
double fahrenheit = celsius * 9/5 + 32;

System.out.println(celsius + " C = " + (fahrenheit) + " F");
scanner.close();

}
}
//creating scanner and object to read inputs
//prompt for user to input
//read what user typed
//calculate the temp from C to F
//close scanner
20 changes: 20 additions & 0 deletions src/TimeConvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.util.Scanner;
public class TimeConvert {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Please Enter Total Number of Seconds: ");

int seconds;
seconds = in.nextInt();

int convertMinutes = seconds/60;
int convertHours = convertMinutes/60;
int convertSeconds = seconds - convertMinutes*60;

System.out.println(convertHours+ " Hours, "+ convertMinutes%60 +" Minutes, and " +convertSeconds +" Seconds");
}
}
//Asking for user input
//reading the input
//calculate the result
//print result