Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7881104

Browse files
Simple Calculator
1 parent f306d03 commit 7881104

File tree

6 files changed

+84
-0
lines changed

6 files changed

+84
-0
lines changed

‎Task-16/.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### IntelliJ IDEA ###
2+
out/
3+
!**/src/main/**/out/
4+
!**/src/test/**/out/
5+
6+
### Eclipse ###
7+
.apt_generated
8+
.classpath
9+
.factorypath
10+
.project
11+
.settings
12+
.springBeans
13+
.sts4-cache
14+
bin/
15+
!**/src/main/**/bin/
16+
!**/src/test/**/bin/
17+
18+
### NetBeans ###
19+
/nbproject/private/
20+
/nbbuild/
21+
/dist/
22+
/nbdist/
23+
/.nb-gradle/
24+
25+
### VS Code ###
26+
.vscode/
27+
28+
### Mac OS ###
29+
.DS_Store

‎Task-16/.idea/.gitignore

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Task-16/.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Task-16/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Task-16/Task-16.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

‎Task-16/src/Main.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//Exercise 16: Simple Calculator
2+
//1. Task: Write a program that acts as a basic calculator. It should take two integers and perform addition, subtraction, multiplication, and division on them. Use int data types for inputs and the result.
3+
//o Hint: You can hardcode the values for this exercise.
4+
//o Expected Output:
5+
//Number 1: [Your First Number]
6+
//Number 2: [Your Second Number]
7+
//Addition: [Result of Addition]
8+
//Subtraction: [Result of Subtraction]
9+
//Multiplication: [Result of Multiplication]
10+
//Division: [Result of Division]
11+
12+
public class Main {
13+
public static void main(String[] args) {
14+
int num1 = 10;
15+
int num2 = 5;
16+
int sum = num1 + num2;
17+
int subtract = num1 - num2;
18+
int multiply = num1 * num2;
19+
int divide = num1 / num2;
20+
System.out.println("Number 1: " + num1);
21+
System.out.println("Number 2: " + num2);
22+
System.out.println("Addition: " + sum);
23+
System.out.println("Subtraction: " + subtract);
24+
System.out.println("Multiplication: " + multiply);
25+
System.out.println("Division: " + divide);
26+
}
27+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /