Skip to content

Commit 02409be

Browse files
Initial commit
0 parents  commit 02409be

File tree

4 files changed

+156
-0
lines changed

4 files changed

+156
-0
lines changed

.github/workflows/main.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
##################################################
2+
3+
4+
# Run Mr Coxall's Super Linter against code base #
5+
6+
7+
##################################################
8+
9+
10+
---
11+
12+
13+
name: Mr Coxall's Super Linter
14+
15+
16+
17+
on: [push, pull_request]
18+
19+
20+
21+
jobs:
22+
23+
24+
run-linters:
25+
26+
27+
name: Mr Coxall's Super Linter
28+
29+
30+
runs-on: ubuntu-latest
31+
32+
33+
34+
steps:
35+
36+
37+
- name: Check out Git repository
38+
39+
40+
uses: actions/checkout@main
41+
42+
43+
- name: Run GitHub Super Linter
44+
45+
46+
uses: github/super-linter@main
47+
48+
49+
env:
50+
51+
52+
VALIDATE_ALL_CODEBASE: true
53+
54+
55+
DISABLE_ERRORS: true
56+
57+
58+
59+
LINTER_RULES_PATH: /
60+
61+
62+
VALIDATE_CLANG_FORMAT: false
63+
64+
65+
VALIDATE_JAVASCRIPT_STANDARD: false
66+
67+
68+
VALIDATE_PYTHON_FLAKE8: false
69+
70+
71+
VALIDATE_GITLEAKS: false # for secrets detection
72+
73+
74+
VALIDATE_JSCPD: false # for copy and paste detection
75+
76+
77+
DEFAULT_BRANCH: main
78+
79+
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Compiled class file
2+
*.class
3+
4+
# Log file
5+
*.log
6+
7+
# BlueJ files
8+
*.ctxt
9+
10+
# Mobile Tools for Java (J2ME)
11+
.mtj.tmp/
12+
13+
# Package Files #
14+
*.jar
15+
*.war
16+
*.nar
17+
*.ear
18+
*.zip
19+
*.tar.gz
20+
*.rar
21+
22+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23+
hs_err_pid*
24+
replay_pid*

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# JAVA-TEMPLATE-
2+
[![Mr Coxall's Super Linter](README.md/../../../workflows/Mr%20Coxall's%20Super%20Linter/badge.svg)](README.md/../../../actions)

code.java

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//import Scanner for user input
2+
import java.util.Scanner;
3+
4+
/**
5+
* This program calculates the volume of a sphere.
6+
*
7+
* @author Dylan Mutabazi
8+
* @version 1.0
9+
* @since 2025-September-11
10+
*/
11+
12+
final class Einstein {
13+
/**
14+
*@exception IllegalStateException
15+
*@see IllegalStateException
16+
*/
17+
private Einstein() {
18+
throw new IllegalStateException("Utility class");
19+
}
20+
21+
// Constant for speed of light
22+
public static final double SPEEDOFLIGHT = 2.998e8;
23+
/**
24+
* Entrypoint of the program.
25+
* @param args UNUSED.
26+
*/
27+
public static void main(final String[] args) {
28+
// Get mass from user.
29+
System.out.println("Input your mass (kg): ");
30+
Scanner massScanner = new Scanner(System.in);
31+
String massString = massScanner.nextLine();
32+
33+
try {
34+
// Converts mass into double.
35+
double massDouble = Double.parseDouble(massString);
36+
// If mass <= 0 prints error line.
37+
if (massDouble <= 0) {
38+
System.out.println("Mass cannot be <= 0");
39+
} else {
40+
// Else calculates energy in joules.
41+
double energy = massDouble * Math.pow(SPEEDOFLIGHT, 2);
42+
System.out.println("the amount of energy released = "
43+
+ String.format("%.3e", energy) + " Joules");
44+
}
45+
} catch (Exception e) {
46+
// If conversion to double doesnt work prints error line.
47+
System.out.println("Invalid input, try again later.");
48+
}
49+
}
50+
}

0 commit comments

Comments
 (0)