-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice_Set_6.java
More file actions
123 lines (110 loc) · 3.73 KB
/
Practice_Set_6.java
File metadata and controls
123 lines (110 loc) · 3.73 KB
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
package com.company;
import java.util.Scanner;
public class Practice_Set_6 {
public static void main(String[] args) {
//Problem 1
Scanner sc = new Scanner(System.in);
// float problem1[];
// problem1 = new float[5];
// for (int i = 0; i != 5; i++ ) {
// System.out.print(" Write your " + (i + 1) + " number : ");
// problem1[i] = sc.nextFloat();
// }
// float answer = 0;
// for (int i = 0; i!=problem1.length; i++){
// answer += problem1[i];
// }
// System.out.println("The sum those 5 numbers is " + answer);
// float[] arr = {22.0f,44f,34f,32f};
// System.out.print("Write your value here : ");
// float value = sc.nextFloat();
// boolean correct = false;
// for (int i = 0; i!=arr.length; i++){
// if (value == arr[i]){
// correct = true;
// break;
// }
// }
// if (correct == true){
// System.out.println("This number is present in the array");
// }else {
// System.out.println("This number is not present in the array");
// }
//Problem 3
// float problem1[];
// problem1 = new float[5];
// for (int i = 0; i != 5; i++ ) {
// System.out.print(" Write your " + (i + 1) + " number : ");
// problem1[i] = sc.nextFloat();
// }
// float answer = 1;
// for (int i = 0; i!=problem1.length; i++){
// answer += problem1[i];
// }
// answer /= 5;
// System.out.println("The sum those 5 numbers is " + answer);
//Problem 4
// int [][] mat1 = {{1, 2, 3},
// {4, 5, 6}};
// int [][] mat2 = {{2, 6, 13},
// {3, 7, 1}};
// int [][] result = {{0, 0, 0},
// {0, 0, 0}};
//
// for (int i=0;i<mat1.length;i++){ // row number of times
// for (int j=0;j<mat1[i].length;j++) { // column number of time
// System.out.format(" Setting value for i=%d and j=%d\n", i, j);
// result[i][j] = mat1[i][j] + mat2[i][j];
// }
// }
//
// // Printing the elements of a 2-D Array
// for (int i=0;i<mat1.length;i++){ // row number of times
// for (int j=0;j<mat1[i].length;j++) { // column number of time
// System.out.print(result[i][j] + " ");
// result[i][j] = mat1[i][j] + mat2[i][j];
// }
// System.out.println(""); // Prints a new line
// }
//Problem 5
/* int [] arr = {1, 21, 3, 4, 5, 34, 67};
int l = arr.length;
int n = Math.floorDiv(l, 2);
int temp;
for(int i=0; i<n; i++){
// Swap a[i] and a[l-1-i]
// a b temp
// |4| |3| ||
temp = arr[i];
arr[i] = arr[l-i-1];
arr[l-i-1] = temp;
}
for(int element: arr){
System.out.print(element + " ");
}*/
//Problem 6
// System.out.println("Maximum Value");
// int[] value = {34,55,78,87};
// int answer = 0;
// int i = 0;
// for (int element: value){
// if (answer < value[i]){
// answer = element;
// }
// i++;
// }
// System.out.println("This is the largest number : " + answer);
//Problem 7
// System.out.println("Maximum Value");
// int[] value = {34,55,78,87};
// int answer = 100;
// int i = 0;
// for (int element: value){
// if (answer > value[i]){
// answer = element;
// }
// i++;
// }
// System.out.println("This smallest number : " + answer);
}
}