Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(A) A company wants to transmit data over thetelephone, but is concerned that it

ID: 3609504 • Letter: #

Question

(A)   A company wants to transmit data over thetelephone, but is concerned that its phones may be tapped. It hasasked you to write a program that will encrypt the data so that itmay be transmitted more securely. All the data is transmitted asfour-digit integers. Your application should read a 4 digit integerentered in by the user and encrypts it as follows: Replace eachdigit with the result of adding 7 to the digit and getting theremainder after dividing the new value by 10. Then swap the 1stdigit with the third,and second with fourth. Print theencrypted integer. Write a seperate application that inputs anencrypted 4digit integer and decrypts it to form the originalnumber. (B)   De Morgan's Laws can sometimes make it moreconvenient for us to express a logical expression. These laws statethat the expression !(condition1 &&condition2) is logically equivalent to the expression(!condition1 | | !condition2). Also, theexpression !(condition 1 | | condition 2) islogically equivalent to (!condition1 &&!condition2). Use De Morgan Laws to write equivalentexpressions for each of the following, then write an application toshow that both the original expression and the new expression ineach case produce the same value:

    - !( x < 5 ) && !( y >= 7 )     - !( a == b) | | !( g != 5 )     - !( ( x <= 8 ) && (y > 4) )     - !( ( i > 4) | | ( j<= 6 ) ) (A)   A company wants to transmit data over thetelephone, but is concerned that its phones may be tapped. It hasasked you to write a program that will encrypt the data so that itmay be transmitted more securely. All the data is transmitted asfour-digit integers. Your application should read a 4 digit integerentered in by the user and encrypts it as follows: Replace eachdigit with the result of adding 7 to the digit and getting theremainder after dividing the new value by 10. Then swap the 1stdigit with the third,and second with fourth. Print theencrypted integer. Write a seperate application that inputs anencrypted 4digit integer and decrypts it to form the originalnumber. (B)   De Morgan's Laws can sometimes make it moreconvenient for us to express a logical expression. These laws statethat the expression !(condition1 &&condition2) is logically equivalent to the expression(!condition1 | | !condition2). Also, theexpression !(condition 1 | | condition 2) islogically equivalent to (!condition1 &&!condition2). Use De Morgan Laws to write equivalentexpressions for each of the following, then write an application toshow that both the original expression and the new expression ineach case produce the same value:

    - !( x < 5 ) && !( y >= 7 )     - !( a == b) | | !( g != 5 )     - !( ( x <= 8 ) && (y > 4) )     - !( ( i > 4) | | ( j<= 6 ) )

Explanation / Answer

import java.util.*;
public class Dietel4_37
{
public static void main(String[] args)
{
int number,digit1,digit2,digit3,digit4;

import java.util.*;
public class DeMorgansLaw
{
public static void main(String[] args)
{System.out.println ("!(a&&b)   vs  (!a||!b)");
System.out.println(!(true&&true) +"  "+(!true||!true));
System.out.println(!(true&&false) +"  "+(!true||!false));
System.out.println(!(false&&true) +"  "+(!false||!true));
System.out.println(!(false&&false) +"  "+(!false||!false));
System.out.println ("!(a||b)   vs  (!a&&!b)");
System.out.println(!(true||true) +"  "+(!true&&!true));
System.out.println(!(true||false) +"  "+(!true&&!false));
System.out.println(!(false||true) +"  "+(!false&&!true));
System.out.println(!(false||false) +"  "+(!false&&!false));

}
}