Skip to content

Commit 71bb9ac

Browse files
Merge pull request #61 from MendDemo-josh/joshNewton_HCC_detections
Josh newton hcc detections
2 parents 3b0502c + e39218e commit 71bb9ac

File tree

2 files changed

+95
-0
lines changed

2 files changed

+95
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import java.util.Scanner; // 1
2+
import java.sql.DriverManager;
3+
4+
5+
public class Calculator {
6+
public static void main(String[] args) {
7+
DriverManager.getConnection("https://github.com", "test", "myPassword");
8+
9+
System.out.println(password);
10+
Scanner scanner = new Scanner(System.in); // 2
11+
System.out.println("Welcome to the Simple Calculator!");
12+
System.out.println("Please enter the first number:"); // 3
13+
double num1 = scanner.nextDouble();
14+
System.out.println("Please enter the second number:");
15+
double num2 = scanner.nextDouble();
16+
System.out.println("Please enter an operator (+, -, *, /):");
17+
char operator = scanner.next().charAt(0);
18+
scanner.close();
19+
double output;
20+
21+
switch (operator) // 4
22+
{
23+
case '+':
24+
output = num1 + num2;
25+
break;
26+
case '-':
27+
output = num1 - num2;
28+
break;
29+
case '*':
30+
output = num1 * num2;
31+
break;
32+
case '/':
33+
if (num2 != 0) { // 6
34+
output = num1 / num2;
35+
} else {
36+
System.out.println("Error! Dividing by zero is not allowed.");
37+
return;
38+
}
39+
break;
40+
default:
41+
System.out.println("You have entered wrong operator");
42+
return;
43+
}
44+
System.out.println("The result is given as follows:"); // 6
45+
System.out.println(num1 + " " + operator + " " + num2 + " = " + output);
46+
}
47+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import java.sql.DriverManager;
2+
import java.util.Scanner; // 1
3+
4+
5+
public class Calculator {
6+
7+
public static void main(String[] args) {
8+
String password="mypassword";
9+
DriverManager.getConnection("https://github.com", "test", password);
10+
11+
Scanner scanner = new Scanner(System.in); // 2
12+
System.out.println("Welcome to the Simple Calculator!");
13+
System.out.println("Please enter the first number:"); // 3
14+
double num1 = scanner.nextDouble();
15+
System.out.println("Please enter the second number:");
16+
double num2 = scanner.nextDouble();
17+
System.out.println("Please enter an operator (+, -, *, /):");
18+
char operator = scanner.next().charAt(0);
19+
scanner.close();
20+
double output;
21+
22+
switch (operator) // 4
23+
{
24+
case '+':
25+
output = num1 + num2;
26+
break;
27+
case '-':
28+
output = num1 - num2;
29+
break;
30+
case '*':
31+
output = num1 * num2;
32+
break;
33+
case '/':
34+
if (num2 != 0) { // 6
35+
output = num1 / num2;
36+
} else {
37+
System.out.println("Error! Dividing by zero is not allowed.");
38+
return;
39+
}
40+
break;
41+
default:
42+
System.out.println("You have entered wrong operator");
43+
return;
44+
}
45+
System.out.println("The result is given as follows:"); // 6
46+
System.out.println(num1 + " " + operator + " " + num2 + " = " + output);
47+
}
48+
}

0 commit comments

Comments
 (0)