The wall of a house consists of two 125mm brick walls with an inner cavity. The inside wall has a 10mm coating of plaster and there is a cement rendering of 5mm on the outside wall. In one room of the house the external wall is 4m by 2.5m
Explain, without using a truth table, why (p ∨ q ∨ r) ∧
(¬p ∨ ¬q ∨ ¬r) is true when at least one of p, q, and r
is true and at least one is false, but is false when all three
variables have the same truth value.
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a String: ");
String string = in.nextLine().toLowerCase();
System.out.print("Enter character to find: ");
String characterFind = in.nextLine().toLowerCase();
int index = string.indexOf(characterFind);
System.out.print("Index Position: ");
while (index >= 0) {
System.out.print(index + " ");
index = string.indexOf(characterFind, index + 1);
}
in.close();
}
}
Do this coding without using characterFind
Write a program in java.io package to take a String as input then display first word all capital letters, second word all small letters, third word all capital letters and so on.
Example:
Enter a String
Asia is the largest continent
ASIA is THE largest CONTINENT
Don't use array and split function
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a String: ");
String words[] = in.nextLine().toLowerCase().split(" ");
for (int i = 0; i < words.length; i++) {
if (i % 2 == 0) {
System.out.print(words[i].toUpperCase() + " ");
} else {
System.out.print(words[i].toLowerCase() + " ");
}
}
in.close();
}
}
Do this programming without using array and split
Write a program to take a name as input then display the signature as the first letter of each word with dot.
Enter a String
Hubert Blaine Wolfeschlegelsteinhausenbergerdorff Sr
H.B.W.S.
Don't use array and split function
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a String: ");
String words[] = in.nextLine().split(" ");
for (int i = 0; i < words.length; i++) {
System.out.print(words[i].toUpperCase().charAt(0) + ".");
}
in.close();
}
}
Do this coding without using array and split
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String names[] = new String[15];
double salaries[] = new double[15];
double salariesTotal = 0;
for (int i = 0; i < names.length; i++) {
System.out.print("Enter employee name " + (i + 1) + ": ");
names[i] = in.nextLine();
System.out.print("Enter employee salary " + (i + 1) + ": ");
salaries[i] = in.nextDouble();
salariesTotal += salaries[i];
in.nextLine();
}
System.out.println();
for (int i = 0; i < names.length; i++) {
System.out.println("Enter employee name: " + names[i]);
System.out.println("Enter employee salary: " + salaries[i]);
}
double averageSalary = salariesTotal / 15.0;
System.out.printf("The average salary employees: %.2f\n", averageSalary);
in.close();
}
}
Do this coding without using array and printf
Write a program to take a String name as input then display the signature using substring().
Example:
Enter a String
Chandra Bahadur Dangi Ailen Coq
C. Bahadur D. Ailen C.
Don't use Array & Split
import java.util.*;
class App {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter a String: ");
String words[] = in.nextLine().split(" ");
for (int i = 0; i < words.length; i++) {
if (i % 2 == 0) {
System.out.print(words[i].substring(0, 1) + ". ");
} else {
System.out.print(words[i] + " ");
}
}
in.close();
}
}
Do this program without using array and split