-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEX1
155 lines (106 loc) · 2.59 KB
/
EX1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Grade
package javaapplication2;
import java.util.*;
class Student{
int marks;
void grade(int m){
if(m>=3 && m<=5){
System.out.println("poor");
}
if(m>=6&&m<=7){
System.out.println("Good");
}
if(m>=8&&m<=9){
System.out.println("Very good");
}
}
}
public class JavaApplication2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println("Enter marks: ");
Scanner m = new Scanner(System.in);
int mark = m.nextInt();
Student s = new Student();
s.grade(mark);
}
}
// sum integers div by 7 btwn 100 to 700
package javaapplication3;
/**
*
* @author admin
*/
import java.util.*;
class integer{
void divbyseven(){
int sum = 0;
for(int i=100; i<700;i++ ){
if(i%7==0){
sum = sum+i;
}
}
System.out.println(sum);
}
}
public class JavaApplication3 {
public static void main(String[] args) {
integer s = new integer();
s.divbyseven();
}
}
//Swap
public class Swap {
public static void main(String[] args) {
float first = 12.0f, second = 24.5f;
System.out.println("--Before swap--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
first = first - second;
second = first + second;
first = second - first;
System.out.println("--After swap--");
System.out.println("First number = " + first);
System.out.println("Second number = " + second);
}
}
//pattern
class Main {
public static void main(String args[]) {
int n = 5;
//Loop to iterate over each row
for(int i=1;i<=n;i++){
//Loop to iterate over each column of the ith row
for(int j=1;j<=i;j++){
System.out.print(i+ " ");
}
System.out.println();
}
}
}
// largest smallest number
package javaapplication1;
/**
*
* @author 22CSEB41
*/
public class JavaApplication1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int numbers[] = new int[]{55,32,45,98,82,11,9,39,50};
int smallest = numbers[0];
int largetst = numbers[0];
for (int i = 1; i < numbers.length; i++) {
if (numbers[i] > largetst)
largetst = numbers[i];
else if (numbers[i] < smallest)
smallest = numbers[i];
}
System.out.println("Largest Number is : " + largetst);
System.out.println("Smallest Number is : " + smallest);
}
}