Skip to content

Commit c9d6e92

Browse files
committed
works
1 parent a2d227d commit c9d6e92

File tree

4 files changed

+39
-3
lines changed

4 files changed

+39
-3
lines changed

app/src/main/java/io/github/project516/JavaTemperatureConverter/Main.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public class Main {
99
public static void main(String[] args) {
1010

1111
System.out.println(info.vendor());
12+
Runtime run = new Runtime();
13+
run.run();
1214
}
1315
}
Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
package io.github.project516.JavaTemperatureConverter;
22

3-
import io.github.project516.jlibutils.ScannerHelper;
3+
import java.nio.charset.StandardCharsets;
4+
import java.util.*;
45

56
public class Runtime {
67

7-
ScannerHelper scan = new ScannerHelper();
8+
Scanner scan = new Scanner(System.in, StandardCharsets.UTF_8.name());
9+
ConvertTemp temp = new ConvertTemp();
810

9-
void run() {}
11+
void run() {
12+
13+
try {
14+
String input = scan.nextLine().toLowerCase();
15+
16+
if (input.equals("f")) {
17+
System.out.println("Enter Celcus");
18+
Double cel = scan.nextDouble();
19+
System.out.println(temp.cToF(cel));
20+
} else if (input.equals("c")) {
21+
System.out.println("Enter Farenghitght");
22+
Double far = scan.nextDouble();
23+
System.out.println(temp.fToC(far));
24+
} else {
25+
System.out.println("Invalid input!");
26+
}
27+
28+
} catch (Exception e) {
29+
System.out.println(e);
30+
}
31+
}
1032
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.github.project516.JavaTemperatureConverter;
2+
3+
public class Text {
4+
void printInst() {
5+
System.out.println(
6+
"Enter f to convert Celcius to Farenght and c to convert Farenght to Celceus\n");
7+
}
8+
}

test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
3+
./gradlew build || exit 1
4+
java -jar app/build/libs/app-all.jar

0 commit comments

Comments
 (0)