You are to create an output showing a Mortgage Table for monies you have borrowe
ID: 3787204 • Letter: Y
Question
You are to create an output showing a Mortgage Table for monies you have borrowed. Given the amount of a mortgage, the rate of interest being charged, the monthly payment, and the amount of tax due on the property (per year), produce a table of principal, interest, tax, payment, and principal left for each month of the mortgage’s existence. First you have to calculate the monthly payment amount before producing an ‘Amortization Schedule’. See the earlier assignment (warm up programs).
it says what to do here
Below is how to calculate interest values; determining the breakdown of each monthly payment
Even though the monthly payment is fixed, the amount of money paid to interest varies each month. The remaining amount is used to pay off the loan itself. The complicated formula above ensures that after 360 payments, the mortgage balance will be $0.
For the first payment, we already know the total amount is $1,342.05. To determine how much of that goes toward interest, we multiply the remaining balance ($250,000) by the monthly interest rate: 250,000 x 0.416% = $1,041.67. The rest goes toward the mortgage balance ($1,342.05 - $1,041.67 = $300.39). So after the first payment, the remaining amount on the mortgage is $249,699.61 ($250,000 - $300.39 = $249,699.61).
The second payment's breakdown is similar except the mortgage balance has decreased. So the portion of the payment going toward interest is now slightly less: $1,040.42 .... ($249,699.61 * 0.416% = $1,040.42). I would also like a column that shows the ‘taxes’ paid each month and that the monthly payment has the taxes added to the monthly mortgage payment. Tax column not shown below.
I need a c++ program to do the following. Also needs to output to a file. I am using xcode.
For your program use the following: the principal is $22,500.00, the interest is 5.37% per year, the tax per year is $350.00, and the number of payments are for 8 years.
You are to produce a table with the appropriate values (the above example plus one column). Make sure you have labels, totals and all the values line up nicely. I like the commas in the big numbers and ‘$’ signs in the front of each number. All money values are to be shown in dollars and cents.
Explanation / Answer
module priory_encoder_case
(
input wire [4:1] x,
output reg [2:0] pcode
);
always @ *
case (x)
4'b1000, 4'b1001 , 4'b1010, 4'b1011 , 4'b1100 , 4'b1101, 4'b1110 , 4'b1111 :
pcode = 3'b100;
4'b0100, 4'b0101 , 4'b0110, 4'b0111 :
pcode = 3'b011 ;
4'b0010, 4'b0011 :
pcode = 3'b010;
4'b0001 :
pcode = 3'b001;
4'b0000 :
pcode = 3'b000;
endcase
endmodule
Note that the forever statement forever @(x[4], x[3],x[2], x[1]) might be written as forever @ * we tend to currently recommend that you just write a take a look at bench for this code and verify that it works. If you've got sifficulty, you'll be able to check it with following take a look at bench
`timescale 1ns / 1ps
module stimulus;
reg [4:1] x;
wire [2:0] pcode;
// Instantiate the Unit underneath take a look at (UUT)
priory_encoder_case uut (
.x(x),
.pcode(pcode)
);
initial begin
// Initialize Inputs
x = 4'b0000;
#20 x = 4'b0001;
#20 x = 4'b0010;
#20 x = 4'b0011;
#20 x = 4'b0100;
#20 x = 4'b0101;
#20 x = 4'b0110;
#20 x = 4'b0111;
#20 x = 4'b1000;
#20 x = 4'b1001;
#20 x = 4'b1010;
#20 x = 4'b1011;
#20 x = 4'b1100;
#20 x = 4'b1101;
#20 x = 4'b1110;
#20 x = 4'b1111;
#40 ;
end
initial begin
$monitor("t=%3d x=%4b,pcode=%3b",$time,x,pcode );
end
endmodule
Notice the utilization of the case statement
4'b1000, 4'b1001 , 4'b1010, 4'b1011 , 4'b1100 , 4'b1101, 4'b1110 , 4'b1111 :
pcode = 3'b100;
When the valley of x matches any of the subsequent values
4'b1000, 4'b1001 , 4'b1010, 4'b1011 , 4'b1100 , 4'b1101, 4'b1110 , 4'b1111 :
The statement next thereto
pcode = 3'b100;
is dead. Notice that this might even be are written as
4'b1000, 4'b1001 , 4'b1010, 4'b1011 , 4'b1100 , 4'b1101, 4'b1110 , 4'b1111 :
begin
pcode = 3'b100;
end
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.