Java Ca
Java Ca
CA 1
SET: 1:
PROGRAM:
import java.util.*;
class s {
int n = scanner.nextInt();
nums[i] = scanner.nextInt();
found[num] = true;
int missingPositive = 1;
if (!found[i]) {
missingPositive = i;
break;
}}
if (missingPositive == n) {
missingPositive = n + 1;
System.out.println(missingPositive);}}
OUTPUT:
SET : 2
ATM:
PROGRAM:
import java.util.*;
public static final int[] denominations = {20, 50, 100, 200, 500};
static {
banknotes[i] = 0;
banknotes[i] += scanner.nextInt();
result[i] = notesToUse;
if (amount == 0) {
banknotes[i] -= result[i];
scanner.close();
OUTPUT:
SET : 3
PROGRAM:
import java.util.*;
import java.util.*;
class m {
int cs = s.nextInt();
a[i][j] = s.nextInt();
System.out.println();
if (a[i][j] == target) {
found = true;
if (j - 1 >= 0 && j + 1 < cs && i + 1 < rs && i - 1 >= 0 && j - 1 >= 0 && j + 1 < cs && i + 1 < rs
&& i - 1 >= 0 ) {
else System.out.println("0");
if (!found) {
System.out.println("0");
}
}
OUTPUT:
SET: 4:
STRING OPERATIONS:
import java.util.*;
class str{
String e = s.nextLine();
System.out.println(count);
String[] w = e.split("\\s+");
int wl =w.length;
System.out.println(wl);
int count1 = 0;
count1+=1;
}
System.out.println(count1);
OUTPUT:
SET : 5
VIRUS INFECTION:
PROGRAM:
import java.util.*;
class v {
int iterations = 0;
int n = strengths.length();
while (true) {
} else {
break;
} else {
break;
if (next[i] != current.charAt(i)) {
changed = true;
iterations++;
if (!changed) {
break;
System.out.println(iterations);
OUTPUT:
SET :6:
QUADRUPLETS
PROGRAM
import java.util.*;
class a1{
a[i] = s.nextInt();
int ta = s.nextInt();
if (a[i]+a[j]+a[k]+a[z] == ta){
result.add(new int[]{a[i],a[j],a[k],a[z]});
System.out.println(Arrays.toString(com));
}
OUTPUT:
SET: 7
BALANCED PARANTHESIS:
PROGRAM:
import java.util.*;
class a{
int rc=0,cc=0,sc=0;
for(int j=0;j<size.length();j++){
char i = size.charAt(j);
if (i == '{'){
cc +=1;
cc -= 1;
System.out.println("false");
else if (i=='['){
sc +=1;
}
else if (i==']'){
sc-=1;
if (sc <0){
System.out.println("false");
else if (i=='('){
rc +=1;
else if (i==')'){
rc -=1;
if (rc<0){
System.out.println("false");
System.out.println("true");
else{
System.out.println("false");
}}
OUTPUT:
SET : 8:
HTML TAGS:
PROGRAM:
import java.util.*;
public class op {
static {
input = scanner.nextLine();
char ch = input.charAt(i);
if (ch == '<') {
result.append(tempContent);
tempContent.setLength(0);
tagName.setLength(0);
isStartTag = true;
if (isEndTag) i++;
isStartTag = false;
if (openTag.equals(currentTag)) {
openTag = "";
result.append(tempContent);
tempContent.setLength(0);
} else {
invalidContent = true;
break;
} else {
if (openTag.isEmpty()) {
openTag = currentTag;
} else {
tempContent.setLength(0);
} else if (isStartTag) {
tagName.append(ch);
} else if (openTag.isEmpty()) {
result.append(ch);
} else {
tempContent.append(ch);
if (invalidContent || !openTag.isEmpty()) {
System.out.println("Output: None");
} else {
}
}
OUTPUT: