Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CSE 2133 - Lab 2 COBOL This lab consists of an interactive program that will gen

ID: 3885860 • Letter: C

Question

CSE 2133 - Lab 2 COBOL

This lab consists of an interactive program that will generate a statement for a single investment that earns interest compounded monthly. This program is to be named lab2.cob. This program will prompt the user for three inputs: the investment amount, the annual interest rate, and the number of months the money will be invested. The program will calculate the total interest earned, the final balance, and the entire account balance schedule for the investment. All output is displayed to the console.

Ensure that the inputs are valid (positive). If an invalid value is provided by the user the program will note why the value was not valid and then ask for the value again. You can assume that all values provided will be numeric.

For variable sizes, allow for investments up to $99,999,999.99, interest rates up to 99.99%, and loans that last for 999 months.

Sample session (user input shown in bold):

Lab2

Enter Investment Amount: 25000

Enter Annual Interest Rate: -4.5

Annual Interest Rate must be positive

Enter Annual Interest Rate: 4.5

Enter Number of Months: 12

Investment Schedule: Month

Beg Balance

Interest

1

$25,000.00

$93.75

2

$25,093.75

$94.10

3

$25,187.85

$94.45

4

$25,282.30

$94.81

5

$25,377.11

$95.16

6

$25,472.27

$95.52

7

$25,567.79

$95.88

8

$25,663.67

$96.24

9

$25,759.91

$96.60

10

$25,856.51

$96.96

11

$25,953.47

$97.33

12

$26,050.80

$97.69

Investment Schedule: Month

Beg Balance

Interest

1

$25,000.00

$93.75

2

$25,093.75

$94.10

3

$25,187.85

$94.45

4

$25,282.30

$94.81

5

$25,377.11

$95.16

6

$25,472.27

$95.52

7

$25,567.79

$95.88

8

$25,663.67

$96.24

9

$25,759.91

$96.60

10

$25,856.51

$96.96

11

$25,953.47

$97.33

12

$26,050.80

$97.69

Explanation / Answer

IDENTIFICATION DIVISION.
PROGRAM-ID. LAB2.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-PRINCIPAL PIC S9(8)V9(3).
01 WS-VAR_T PIC S9(1)V9(10).
01 WS-VAR_R PIC S9(1)V9(5).
01 WS-VAR1 PIC S9(12)V9(3).
01 WS-INTERSET_AMOUNT PIC S9(12)V9(3).
01 WS-INTEREST PIC S9(2)V9(3).
01 WS-MONTHS PIC S9(3).
01 WS-COUNTER PIC 9(4) VALUE ZERO.

PROCEDURE DIVISION.
A-PARA.
PERFORM B-PARA UNTIL WS-PRINCIPAL>ZERO
PERFORM C-PARA UNTIL WS-INTEREST>ZERO
PERFORM D-PARA UNTIL WS-MONTHS>ZERO
PERFORM E-PARA UNTIL WS-COUNTER>=WS-MONTHS
STOP RUN.


B-PARA.
DISPLAY "ENTER INVESTMENT AMOUNT :"
ACCEPT WS-PRINCIPAL.
IF WS-PRINCIPAL < ZERO
DISPLAY "INVESTMENT AMOUNT MUST BE POSITIVE"
END-IF.
  
C-PARA.
DISPLAY "ENTER ANNUAL INTEREST RATE :"
ACCEPT WS-INTEREST.
IF WS-INTEREST < ZERO
DISPLAY "ANNUAL INTEREST RATE MUST BE POSITIVE"
END-IF.

D-PARA.
DISPLAY "ENTER NUMBER OF MONTHS :"
ACCEPT WS-MONTHS.
IF WS-MONTHS < ZERO
DISPLAY "NUMBER OF MONTHS MUST BE POSITIVE"
END-IF.

E-PARA.
ADD 1 TO WS-COUNTER.
DISPLAY "INVESTMENT SCHEDULE: MONTH : " WS-COUNTER.
DISPLAY "BEG BALANCE : " WS-PRINCIPAL.
DIVIDE 1 BY 12 GIVING WS-VAR_T.
DIVIDE WS-INTEREST BY 100 GIVING WS-VAR_R.
MULTIPLY WS-PRINCIPAL BY WS-VAR_T GIVING WS-VAR1.
MULTIPLY WS-VAR1 BY WS-VAR_R GIVING WS-INTERSET_AMOUNT.
DISPLAY "INTEREST : " WS-INTERSET_AMOUNT.
ADD WS-INTERSET_AMOUNT TO WS-PRINCIPAL.
DISPLAY " ".