Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Day14B {
- public static void main(String[] args) {
- String message = "Vdpsoh Whaw";//"Sample Text";
- char[] charArray = message.toCharArray();
- int shiftAmount = 3;
- for (int i = 0; i < charArray.length; i++) {
- if (Character.isLetter(charArray[i])) {
- char shifted = (char) (charArray[i] + shiftAmount);
- if ((Character.isUpperCase(charArray[i]) && shifted > 'Z')
- || (Character.isLowerCase(charArray[i]) && shifted > 'z') ) {
- shifted -= 26;
- }
- charArray[i] = shifted;
- }
- }
- String encMsg = new String(charArray);
- System.out.println("Original String: " + message);
- System.out.println("Caesar Cipher: " + encMsg);
- }
- String encryptMsg() {
- String result="";
- return result;
- }
- }
- //-------------------------------------------------------
- package week3;
- public class Day14D extends SampleParent { // 1 parent class only
- public static void main(String[] args) {
- Day14D callMe = new Day14D();
- System.out.println("12 + 9.82 = " + callMe.sum(12, 9.82));
- callMe.printLorem();
- System.out.println("4.22 + 6.7 + 12.86 = " + callMe.sum(4.22, 6.7, 12.86));
- System.out.println("4.25 + 19.50 + 15.75 + 42.75 = "
- + callMe.sum(4.25, 19.50, 15.75, 42.75));
- System.out.println("-------------");
- double[] numArray = {28.01, 23.56, 25.64, 20.11, 17.55, 5.36, 10.46};
- System.out.println(callMe.sum(numArray));
- }
- @Override
- void printLorem() {
- super.printLorem();
- System.out.print("Donec mollis ex id ipsum imperdiet,");
- System.out.print(" ultricies euismod metus facilisis. ");
- System.out.println("Aliquam nec ullamcorper dui. ");
- }
- // method overloading
- Double sum(double n1, double n2, double n3) {
- double result = super.sum(n1, n2) + n3;
- return result;
- }
- Double sum(double n1, double n2, double n3, double n4) {
- double result = sum(n1, n2, n3) + n4;
- return result;
- }
- double sum(double[] numList) {
- double result = 0;
- // add a formula here that will compute the total of all the numbers in an array
- return result;
- }
- }
- class SampleParent {
- Double sum(double n1, double n2) {
- double result = n1 + n2;
- return result;
- }
- void printLorem() {
- System.out.print("Lorem ipsum dolor sit amet,");
- System.out.print("consectetur adipiscing elit, ");
- System.out.print("sed do eiusmod tempor incididunt ");
- System.out.println("ut labore et dolore magna aliqua.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment