De Morgan’s Laws. We have discussed the logical operators &&, ||, ^ and !. De Morgan’s Laws can sometimes make it more convenient for us to express a logical expression. These laws state that the expression !(condition1 && condition2) is logically equivalent to the expression (!condition1 || !condition2). Also, the expression !(condition1 || condition2) is logically equivalent to the expression (!condition1 && !condition2). Use De Morgan’s Law to write equivalent expressions for each of the following, and then write a program to show that both the original expression and the new expression in each case are equivalent:
a. !(x<5) && !(y>=7)
b. !(a==b) || !(g!=5)
c. !(x<=8) && (y>4)
d. !((i>4) || (j<=6))
Name your program as DeMorgansLaw.java

DaniWeb Member Rules include:
"Do provide evidence of having done some work yourself if posting questions from school or work assignments"
http://www.daniweb.com/community/rules

thats my answer can someone help me to tell me where did i go wrong?

import java.util.Scanner;

class DeMorganLaws {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int a,b,g,i,j,x,y;

System.out.print("\nEnter value of a b g i j x y :");
a = sc.nextInt();b = sc.nextInt();g = sc.nextInt();
i = sc.nextInt();j = sc.nextInt();x = sc.nextInt();
y = sc.nextInt();

System.out.println("a)");
System.out.println("Original expression : !( x < 5 ) && !( y >= 7) = " + (!( x < 5 ) && !( y >= 7)));
System.out.println("     New expression : !(( x < 5 ) || ( y >= 7)) = " + (!(( x < 5 ) || ( y >= 7))));

System.out.println("\nb)");
System.out.println("Original expression : !( a == b ) || !( g != 5) = " + (!( a == b ) || !( g != 5)));
System.out.println("     New expression : !(( a == b ) && ( g != 5)) = " + (!(( a == b ) && ( g != 5))));

System.out.println("\nc)");
System.out.println("Original expression : !(( x  4)) = " + (!(( x  4))));
System.out.println("     New expression : !( x  4) = " + (!( x  4)));

System.out.println("\nd)");
System.out.println("Original expression : !(( i > 4 ) || ( j  4 ) && !( j  4 ) && !( j System.out.println();
}

}

That looks reasonable - so what happens when you execute it - do you get the correect results or what? What help do you need exactly?

this my error i get

line 21 ')'
line 21 ';'
line 22 ')'
line 22 ';'
line 25 unclosed string literal
line 25 ';'
line 26 illegal start of expression
line 26 ';'expected

line 25 unclosed string literal
On line 24 you start a string literal with a ", but you never close it - you missed the final " (the colour coding in DaniWeb code diplay is a clue) Then later on line 4 you seem to jump into another statement altogether (looks like a line got lost somewhere?)

jamescherrill i dont get it. how pls can you tell me?

Can you work on the errors one at a time?
Comment out (add // in column 1) all the lines with errors on them except the first line with an error.
Compile the code and copy the full text of the error message and the line with the error and paste them here. Work on fixing that error. When it's fixed, uncomment the next line and do it again.

A suggestion for your next program: Do a compile after entering a few lines, fix the errors before adding any more lines. That way you'll never end up with so many errors at one time.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.