Professional Documents
Culture Documents
Task Performance in Java (Pre-Finals) : Ma. Marivic D. Olaso BSIT - 112
Task Performance in Java (Pre-Finals) : Ma. Marivic D. Olaso BSIT - 112
import java.lang.*;
int x = index + 3;
remove.deleteCharAt(index);
} else {
remove.deleteCharAt(index);
remove.deleteCharAt(x);
}
Output
CODINGS
importjava.util.Scanner;
publicclass TaskPerf2 {
intl = sample.length();
String classify = "";
for (inti = 0; i<l; i++)
{
classify += sample.substring(i,i+1) + sample.substring(i, i+1) + sample.substring(i, i+1);
}
returnclassify;
publicstaticvoidmain(String[] args) {
}
Output
CODINGS
importjava.util.Scanner;
publicclass TaskPerf3 {
publicstaticcharindex;
publicstaticvoidmain(String[] args) {
TaskPerf3 qq = new TaskPerf3();
Scanner sc = newScanner(System.in);
System.out.println("Please enter a sentence:");
String sent = sc.nextLine();
System.out.println("Enter a letter so we can remove the letter on that index");
index = sc.next().charAt(0);
}
public String removeChar(String sent1) {
String finalString = "";
intl = sent1.length();
for(inti = 0; i<l; i++) {
chartest = sent1.charAt(i);
if(! (i> 0 &&i<l - 1 &&test == index))
finalString = finalString + test;
}
returnfinalString;
}
Output
CODINGS
import java.util.Scanner;
import javax.swing.JOptionPane;
int trial = 0;
int maxTries = 8;
int counter = 8;
System.out.println("You have to guess the given word of the admin and you only have 9 tries:");
do {
tries = sc.nextLine();
if(tries.equals(secret)) {
break;
else {
counter--;
System.out.println("Incorrect! The word you enter does not match the secret
game. Please try again.");
if(trial == maxTries) {