1. A shift register, as shown below, is a cascade of flip flops, sharing the sam
ID: 3592032 • Letter: 1
Question
1. A shift register, as shown below, is a cascade of flip flops, sharing the same clock, in which the output of each flip-flop is connected to the 'data' input of the next flip-flop in the chain, resulting in a circuit that shifts by one position the bit array' stored in it, shifting in' the data present at its input and 'shifting out' the last bit in the array, at each transition of the clock. Suppose we have two shift registers, each holding a 4-bit number. Design a circuit to add these two 4-bit numbers and write the result back onto the first one, which in this accumulator 23 serves as an case 02 24 Data In Clock 2. Design a 4-bit BCD counter using four D flip-flops with an additional input called DS (double speed); when DSis 1 the counter advances in steps of two. For example, if the current BCD value is 3 and DS is changed from 0 to 1, in the next clock cycle the counter will have a BCD value of 5 (instead of 4)Explanation / Answer
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
*
*/
public class Account {
private int AcctNo, Cid;
private double Balance;
private String Type;
public int getAcctNo() {
return AcctNo;
}
public void setAcctNo(int AcctNo) {
this.AcctNo = AcctNo;
}
public int getCid() {
return Cid;
}
public void setCid(int Cid) {
this.Cid = Cid;
}
public double getBalance() {
return Balance;
}
public void setBalance(double Balance) {
this.Balance = Balance;
}
public String getType() {
return Type;
}
public void setType(String Type) {
this.Type = Type;
}
public void selectDB(int acctNo) {
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection conn = DriverManager.getConnection("jdbc:ucanaccess://D:ChattBankMDB.mdb");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("Select * from Accounts where AcctNo = " + acctNo);
while (rs.next()) {
setAcctNo(rs.getInt(1));
setCid(rs.getInt(2));
setType(rs.getString(3));
setBalance(rs.getDouble(4));
}
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public void deposit(double amt) {
setBalance(getBalance() + amt);
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection con = DriverManager.getConnection("jdbc:ucanaccess://D:ChattBankMDB.mdb");
Statement stmt = con.createStatement();
stmt.executeUpdate("update Accounts set [Balance] ="+getBalance()+" where [AcctNo] = "+getAcctNo());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public void withdraw (double amt) {
setBalance(getBalance() - amt);
try {
Class.forName("net.ucanaccess.jdbc.UcanaccessDriver");
Connection con = DriverManager.getConnection("jdbc:ucanaccess://D:ChattBankMDB.mdb");
Statement stmt = con.createStatement();
stmt.executeUpdate("update Accounts set [Balance] ="+getBalance()+" where [AcctNo] = "+getAcctNo());
} catch (Exception e) {
System.out.println(e.getMessage());
}
}
public void display(){
JOptionPane.showMessageDialog(null,"Balance = "+getBalance());
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.