oop theory assignment BISMA
oop theory assignment BISMA
Assignment 1
TASK 1
Question:
A Caesar cipher is a simple encryption technique where each letter of a message is shifted forward in the
alphabet by a given number of places.
Solution:
Code:
public class OoptAss1T1 {
// bulitin class
for (char c: line.toCharArray()) { // for each loop to covert the line string into the array of character
char base = Character.isUpperCase(c)? 'A’: 'a’; // will encrypt on the bases of cases (lower or
upper)
} else {
Output:
4
TASK 2
Question:
Write a java program that prompts the user for their full name and generates a pattern based on the
given input.
Solution:
Code:
public class OopstAss1T2 {
System.out.println(name.substring(0, i));
}
5
System.out.println(name.substring(0, i));
System.out.println();
Output: