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>
16 changes: 16 additions & 0 deletions src/TempConvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import java.util.Scanner;

public class TempConvert {
public static void main(String[] args) {
double conversion;
Scanner in = new Scanner(System.in);
System.out.print("Type a temperature in Celsius and I will calculate it into Fahrenheit: ");
conversion = in.nextInt();
System.out.printf(conversion + " Celsius is "+"%.1f Fahrenheit", (conversion*1.8+32));
}
}
//Prompt the user for input.
//Read a double value from the keyboard.
//Calculate the result using the formula: F = C × 9/5 + 32.
//Format the output to one decimal place.
//Test the program by entering a temperature in Celsius.
19 changes: 19 additions & 0 deletions src/TimeConvert.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import java.util.Scanner;

public class TimeConvert {
public static void main(String[] args) {
int seconds;
Scanner in = new Scanner(System.in);
System.out.print("Enter an amount of seconds: ");
seconds = in.nextInt();
int convMinutes = seconds/60;
int convHours = convMinutes/60;
int convSeconds = seconds - convMinutes*60;
System.out.println(convHours+" hours, "+ convMinutes%60 +" minutes, and " +convSeconds +" seconds");
}
}

//Prompt the user for input.
//Read an integer from the keyboard (total number of seconds).
//Calculate the result using the modulus operator.
//Use printf to display the output in the format: "5000 seconds = 1 hours, 23 minutes, and 20 seconds".
Binary file added src/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 src/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 src/error03.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.