Skip to content

Commit 0ec562a

Browse files
committed
Ex 3.2 is done.
1 parent 31010c0 commit 0ec562a

7 files changed

Lines changed: 30 additions & 0 deletions

File tree

File renamed without changes.
File renamed without changes.
File renamed without changes.

‎ch02/Time.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
public class Time {
2+
public static void main(String[] args) {
3+
int hour = 22;
4+
int minute = 44;
5+
int second = 59;
6+
7+
int secondsSinceMidNight = (22 * 60 * 60) + 59;
8+
System.out.println(secondsSinceMidNight);
9+
10+
int secondsRemaining = (24 * 60 * 60) - secondsSinceMidNight;
11+
System.out.println(secondsRemaining);
12+
13+
double percentagePast = (secondsSinceMidNight * 100.0) / (24.0 * 60.0 * 60.0);
14+
System.out.println(percentagePast);
15+
}
16+
}

‎ch03/TempConverter.java‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.util.Scanner;
2+
3+
public class TempConverter {
4+
public static void main(String[] args) {
5+
double Celsius;
6+
Scanner userInput = new Scanner(System.in);
7+
8+
System.out.print("Enter a temperature in Celsius: ");
9+
Celsius = userInput.nextDouble();
10+
double Fahrenheit = (Celsius * 9/5) + 32;
11+
12+
System.out.printf("%.1f C = %.2f F\n", Celsius, Fahrenheit);
13+
}
14+
}

0 commit comments

Comments
 (0)