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
6 changes: 6 additions & 0 deletions .idea/vcs.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-Assignment-002.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="jdk" jdkName="21 (3)" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
34 changes: 34 additions & 0 deletions src/Time.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
*
* @author Tyler Snyder
*/
public class Time {
public static void main(String[] args) {
int hour = 10;
int minute = 29;
int second = 43;
//Define variables and assign values that approximate current time.

int minSinceMidnight = (hour * 60 + minute);
int secSinceMidnight = (minSinceMidnight * 60 + second);
System.out.printf("Number of seconds since midnight: %d\n", secSinceMidnight);
//Calculate and display number of seconds since midnight.

int secInDay = 86400;
int secRemainingInDay = (secInDay - secSinceMidnight);
System.out.printf("There are %d seconds remaining in the day\n", secRemainingInDay);
//Calculate and display number of seconds remaining in the day.

double percentDayPast =( (double)secSinceMidnight / (double)secInDay ) * 100;
System.out.printf("%f percent of the day has past\n", percentDayPast);
//Calculate and display percent of the day that has past.

hour = 11;
minute = 22;
second = 30;
int currentTime = (hour * 60 + minute) * 60 + second;
int timeElapsedMinutes = (currentTime - secSinceMidnight) / 60;
System.out.printf("%d minutes have elapsed since starting this exercise\n", timeElapsedMinutes);
//Modify variable values to reflect current time at end of exercise and calculate time elapsed.
}
}