prog2.java
/* This Java example shows how to declare and use Java primitive boolean variables. The output is a HTML document. */ public class prog2 { public static void main( String[] args ) { boolean[] a = {false, true, false, true, false, true, false, true}; boolean[] b = {false, false, true, true, false, false, true, true}; boolean[] c = {false, false, false, false, true, true, true, true}; int s, d1, d0, f1, f2; System.out.println("<html>\n<head><title>Multiplexer</title></head>\n<body>"); System.out.println("<p><table border>"); System.out.println("<tr><th>S<th>D1<th>D0<th>F1<th>F2"); for (int i=0; i<a.length; i++) { boolean f = (a[i] && !c[i]) || (b[i] && c[i]); s = c[i]? 1: 0; d1 = b[i]? 1: 0; d0 = a[i]? 1: 0; f1 = f? 1: 0; f2 = c[i]? d1: d0; System.out.printf("<tr align=center><td>%d<td>%d<td>%d<td>%d<td>%d\n",s,d1,d0,f1,f2); } System.out.println("</table>\n</body>\n</html>"); } }
S | D1 | D0 | F1 | F2 |
---|---|---|---|---|
0 | 0 | 0 | 0 | 0 |
0 | 0 | 1 | 1 | 1 |
0 | 1 | 0 | 0 | 0 |
0 | 1 | 1 | 1 | 1 |
1 | 0 | 0 | 0 | 0 |
1 | 0 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 1 | 1 |
Maintained by John Loomis, updated Mon Sep 05 20:17:14 2011