Python Programming Use For Loops only You are to ask the use

Python Programming:

Use For Loops only:

You are to ask the user how many stocks they want to input. For example, How many stocks do you want to enter now? Then your program must only allow user to enter 3 sets of stocks and output 3 sets of stocks.

1.The name of the Stock

2.Number of shares Joe bought

3.Stock purchase price

4.Stock selling price

5.Broker commission Displays the following paid for the stock(s) that Joe had transacted (if Joe entered 5 sets of stocks transactions then output 5 sets of stocks).

1.The Name of the Stock

2.The amount of money Joe paid for the stock (number of shares bought * purchase price)

3.The amount of commission Joe paid his broker when he bought the stock. (Amount he paid for stocks * commission in percent)

4.The amount that Jim sold the stock for. (number of shares * selling price)

5.The amount of commission Joe paid his broker when he sold the stock. (Amount he sold shares *commission in percent)

6.Display the amount of money Joe had left when he sold the stock and paid his broker (both times). If this amount is positive, then Joe made a profit. If the amount is negative, then Joe lost money. Profit/loss =(amount sold stocks for-commission)–(amount paid for stocks + commission)

Solution

// A Dynamic Programming primarily based resolution that uses table C[][] to

// calculate the Binomial constant

#include<stdio.h>

// paradigm of a utility operate that returns minimum of 2 integers

int min(int a, int b);

// Returns worth of Binomial constant C(n, k)

int binomialCoeff(int n, int k)

{

    int C[n+1][k+1];

    int i, j;

    // Caculate worth of Binomial constant in bottom up manner

    for (i = 0; i <= n; i++)

    zero || j == i)

                C[i][j] = 1;

            // Calculate worth victimization previosly keep values

            else

                C[i][j] = C[i-1][j-1] + C[i-1][j];

        }

    }

come back C[n][k];

}

// A utility operate to come back minimum of 2 integers

int min(int a, int b)

{

come back (a<b)? a: b;

}

/* Drier program to check on top of function*/

int main()

main:

j mm

mm:

la $a3, array_A # base address for array_A loaded into $a3

la $a1, array_B # base address for array_B loaded into $a1

la $a2, array_C # base address for array_C loaded into $a2

li $t1, four # $t1 = four (row-size and loop end)

li $s0, zero # i = 0; initialize first for loop

loop1:

li $s1, zero # j = 0; restart 2d for loop

loop2:

li $s2, zero # k = 0; restart third for loop

sll $t2, $s0, two # $t2 = i * four (size of row of c)

addu $t2, $t2, $s1 # $t2 = i * size(row) + j

sll $t2, $t2, two # $t2 = computer memory unit offset of [i][j]

addu $t2, $a2, $t2 # $t2 = computer memory unit offset of [i][j]

lw $t4, 0($t2) # $t4 = two bytes of c[i][j]

loop3:

sll $t0, $s2, two # $t0 = k * four (size of row of b)

addu $t0, $t0, $s1 # $t0 = k * size(row) + j

sll $t0, $t0, two # $t0 = computer memory unit offset off [k][j]

addu $t0, $a1, $t0 # $t0 = computer memory unit address of b[k][j]

lw $t5, 0($t0) # $t5 = two bytes of b[k][j]

sll $t0, $s0, two # $t0 = i * four (size of row of a)

addu $t0, $t0, $s2 # $t0 = i * size(row) + k

sll $t0, $t0, two # $t0 = computer memory unit offset of [i][k]

addu $t0, $a3, $t0 # $t0 = computer memory unit address of a[i][k]

lw $t6, 0($t0) # $t6 = two bytes of a[i][k]

mul $t5, $t6, $t5 # $t5 = a[i][k] * b[k][j]

add $t4, $t4, $t5 # $t4 = c[i][j] + a[i][k] * b[k][j]

Python Programming: Use For Loops only: You are to ask the user how many stocks they want to input. For example, How many stocks do you want to enter now? Then
Python Programming: Use For Loops only: You are to ask the user how many stocks they want to input. For example, How many stocks do you want to enter now? Then
Python Programming: Use For Loops only: You are to ask the user how many stocks they want to input. For example, How many stocks do you want to enter now? Then

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site