Skip to content

Commit a6691ce

Browse files
committed
Fundamentals
1 parent 13e6b5c commit a6691ce

File tree

5 files changed

+86
-0
lines changed

5 files changed

+86
-0
lines changed

Fundamentals/AddTwoNumber.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*
2+
* Take 2 inputs from user and add them.
3+
*/
4+
import java.util.Scanner;
5+
public class AddTwoNumber
6+
{
7+
public static void main(String[] args)
8+
{
9+
System.out.println("Enter the input");
10+
Scanner s= new Scanner(System.in);
11+
int num1 = s.nextInt();
12+
int num2 = s.nextInt();
13+
14+
int ans =num1+num2;
15+
System.out.println("Sum of "+ num1 + " + " + num2 + " = " + ans);
16+
}
17+
}
18+

Fundamentals/AddingCharacters.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*
2+
*Store and print characters and Add them.
3+
*/
4+
public class AddingCharacters {
5+
public static void main(String[] args) {
6+
7+
char ch1 , ch2;
8+
ch1= 65; //ASCII value for ‘A’
9+
ch2 = 'Y';
10+
System.out.println(ch1 +" "+ ch2);
11+
System.out.println(ch1+ch2);
12+
}
13+
}

Fundamentals/AverageMarks.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
Write a program to input a name(as a single character) and marks of three tests as m1, m2, and m3 of a student considering all the three marks have been given in integer format.
3+
4+
Now, you need to calculate the average of the given marks and print it.
5+
6+
All the test marks are in integers and hence calculate the average in integer as well. That is, you need to print the integer part of the average only and neglect the decimal part.
7+
*/
8+
import java.util.Scanner;
9+
public class AverageMarks {
10+
public static void main(String[] args)
11+
{
12+
System.out.println("Enter name as a single character");
13+
Scanner s = new Scanner(System.in);
14+
String str = s.next();
15+
char ch = str.charAt(0); // character input
16+
17+
System.out.println("Enter marks m1, m2,m3");
18+
int m1,m2,m3;
19+
m1 = s.nextInt();
20+
m2= s.nextInt();
21+
m3= s.nextInt();
22+
23+
int avg = (m1+m2+m3)/3;
24+
System.out.println(ch);
25+
System.out.println(avg);
26+
}
27+
}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* Calculate Simple Interest.
3+
*/
4+
import java.util.Scanner;
5+
public class CalculateSimpleInterest {
6+
public static void main(String[] args) {
7+
Scanner s = new Scanner(System.in);
8+
9+
System.out.println("Enter rate");
10+
double rate = s.nextDouble();
11+
12+
System.out.println("Enter time");
13+
double time = s.nextDouble();
14+
15+
System.out.println("Enter Principal");
16+
double Principal = s.nextDouble();
17+
18+
double SimpleInterest = (Principal*rate*time)/100;
19+
System.out.println("Simple Interest = "+ SimpleInterest);
20+
}
21+
}

Fundamentals/HelloWorld.java

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
public class HelloWorld {
2+
3+
public static void main(String[] args) {
4+
System.out.println("Hello World");
5+
}
6+
7+
}

0 commit comments

Comments
 (0)