I'm a noob at C++ and this is the first assignment in my class. I'm not sure If I did it right. Can someone please check and correct it please? Thank you

Question:
develop the pseudo code for the following:
Negotiating a consumer loan is not always straight forward. One form of loan is the discount installment loan, which works as follows. Suppose a loan has a face value of $1000, the interest rate is 15%, and the duration is 18 months. The interest is computed by multiplying the face value of $1000 by 0.15 yielding $150.0. That figure is then multiplied by the loan period of 1.5 years to yield $225 as the total interest owed, that amount is immediately deducted from the face value, leaving the consumer with only $775.00. Repayment is made in equal monthly installments based upon the face value. So the monthly payment will be $1000 divided by 18, which is $55.56. This method of calculation may not be too bad if the consumer needs $775 dollars, but the calculation is a bit more complicated if the consumer needs $1000. Write the pseudo code which would take 3 inputs, the amount the consumer needs to receive, the interest rate and the duration of the loan in months. The pseudo code should also make sure to calculate the face value required in order for the consumer to receive the amount needed and calculate the monthly payment.

My Answer:
Set the value of loan to $1000
Set the value of interest rate to .15
WHILE Set the value of months to 18 DO
Set the value of years to (months / 12 = 1.5)
WHILE (face value * interest rate = $150) DO
Set the value of total interest owed to ($150 * years = $225)
Set the value of remaining loan value to (loan – total interest = $775)
Set monthly payment to (loan / months = $55.56)

Print out the values of loan and monthly payment.

Dani AI

Generated

made a good start but the posted pseudo is mixing fixed test values with control-structure syntax (the WHILE blocks are not appropriate here) and it never reads the three required inputs. correctly isolated the face value algebraically; that is the right idea. The missing pieces are: clear input handling, unit conversions (months -> years and percent -> decimal), input validation (months > 0 and the denominator must be positive), and rounding the monthly payment to cents.

A compact, language-agnostic pseudocode that covers those points:

READ neededAmount         // amount the consumer must receive
READ annualRatePercent    // e.g. 15 for 15%
READ months               // loan duration in months

annualRate = annualRatePercent / 100.0
years = months / 12.0

denominator = 1.0 - (annualRate * years)
IF months <= 0 OR denominator <= 0 THEN
  REPORT error: "invalid loan terms"      // interest too large or zero months
ELSE
  faceValue = neededAmount / denominator
  monthlyPayment = faceValue / months
  PRINT faceValue (use floating type)
  PRINT monthlyPayment (round to 2 decimal places)
END IF

Notes and cautions:

  • Use a floating type (double) for calculations so fractional cents are handled. Convert percent input to decimal early to avoid confusion.
  • If annualRate * years >= 1 the formula breaks (the borrower would need infinite or negative face value) — detect and report that as invalid.
  • Round displayed monthly payment to two decimal places for currency, but keep full precision in intermediate math.
  • For a classroom pseudo-code assignment, this structure shows correct inputs, processing, validation, and outputs without hardcoding example numbers.

Suppose a loan has a face value of $1000, the interest rate is 15%, and the duration is 18 months. The interest is computed by multiplying the face value of $1000 by 0.15 yielding $150.0. That figure is then multiplied by the loan period of 1.5 years to yield $225 as the total interest owed, that amount is immediately deducted from the face value, leaving the consumer with only $775.00.

Therefore the simplified formula is as following:

Received Value = Face Value * (1 - Interest Rate * Duration)
775            = 1000       * (1 - 0.15          * 1.5     )

but the calculation is a bit more complicated if the consumer needs $1000.

No true. It is not complicated. The formula is as following

                    Received Value
Face Value = --------------------------------
               1 - Interest Rate * Duration

              1000.000
1290.3225 =  ---------------
              1 - 0.15 * 1.5

If customer want to receive $1000 with 1.5 years duration and 15% interest, he/she need 1290.3225 face value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.