Question

In: Computer Science

Cant figure out why my out is wrong for my c++ program. for example if the...

Cant figure out why my out is wrong for my c++ program.

for example if the initial value is 100, the intrest rate is 10%, and it takes 6 months for maturity the output should be $105 but instead it outputs 101.657 please help.

#include <iostream>

#include <cmath>

using namespace std;

struct account

{

double balance;

double interest_rate;

int term;

};

void info(account& accountinfo);

int main(void)

{

double calc1, calc2, calc3;

account accountinfo;

info(accountinfo);

calc1 = accountinfo.interest_rate / 100;

calc2 = accountinfo.term / 12;

calc3 = (accountinfo.balance * pow (1 + calc1 / 365, 365 / accountinfo.term));

cout << " " << endl

<< " The balance of your CD account after it has matured in " << accountinfo.term << " months " << endl

<< " at a interest rate of " << accountinfo.interest_rate << " percent will be " << calc3 << endl

<< " " << endl;

return 0;

}

void info(account& accountinfo)

{

cout << " " << endl

<< " This program calculates the value of a CD after maturity. " << endl

<< " " << endl

<< " Enter the balance on the account. " << endl;

cin >> accountinfo.balance;

cout << " " << endl

<< " Enter the interest rate for the CD. " << endl

<< " " << endl;

cin >> accountinfo.interest_rate;

cout << " " << endl

<< " Enter the term for the CD to achieve maturity (in months). " << endl

<< " " << endl;

cin >> accountinfo.term;

}

Solutions

Expert Solution

CODE:-

#include <iostream>

#include <cmath>

using namespace std;

struct account

{

double balance;

double interest_rate;

int term;

};

void info(account& accountinfo);

int main(void)

{

double calc1, calc2, calc3;

account accountinfo;

info(accountinfo);

calc1 = accountinfo.interest_rate/100 ;
calc2 =accountinfo.term /12.0;
calc3 = (accountinfo.balance*(1 +(calc1*calc2)));
// modification on the above line A=p(1+rt) here r=calc1 t=calc2
cout << " " << endl << " The balance of your CD account after it has matured in " << accountinfo.term << " months " << endl
<< " at a interest rate of " << accountinfo.interest_rate << " percent will be " << calc3 << endl << " " << endl;

return 0;

}

void info(account& accountinfo)

{

    cout << " " << endl
  
    << " This program calculates the value of a CD after maturity. " << endl
  
    << " " << endl
  
    << " Enter the balance on the account. " << endl;
  
    cin >> accountinfo.balance;
  
    cout << " " << endl
  
    << " Enter the interest rate for the CD. " << endl
  
    << " " << endl;
  
    cin >> accountinfo.interest_rate;
  
    cout << " " << endl
  
    << " Enter the term for the CD to achieve maturity (in months). " << endl
  
    << " " << endl;
  
    cin >> accountinfo.term;
}


Related Solutions

What I have bolded is what is wrong with this function and cant figure out what...
What I have bolded is what is wrong with this function and cant figure out what needs to bee done to get the second position of this comma?Need help building this function to do what the specifications say to do import introcs def second_in_list(s): """ Returns: the second item in comma-separated list    The final result should not have any whitespace around the edges.    Example: second_in_list('apple, banana, orange') returns 'banana' Example: second_in_list(' do , re , me , fa...
Cant seem to figure out what is wrong here? On December 31, after adjustments, Gonzalez Company's...
Cant seem to figure out what is wrong here? On December 31, after adjustments, Gonzalez Company's ledger contains the following account balances: 101 Cash $ 94,400 Dr. 111 Accounts Receivable 35,600 Dr. 121 Supplies 8,000 Dr. 131 Prepaid Rent 81,200 Dr. 141 Equipment 128,000 Dr. 142 Accumulated Depreciation—Equip. 4,000 Cr. 202 Accounts Payable 17,000 Cr. 301 Emilio Gonzalez, Capital (12/1/2019) 131,240 Cr. 302 Emilio Gonzalez, Drawing 16,400 Dr. 401 Fees Income 327,200 Cr. 511 Advertising Expense 11,600 Dr. 514 Depreciation...
Cannot figure out why my c++ program keeps crashing, I am attempting to have the user...
Cannot figure out why my c++ program keeps crashing, I am attempting to have the user decide the size of a 2d array then fill said array. #include <iostream> using namespace std; typedef int* IntArrayPtr; int main(void) { int column, row, i, j; IntArrayPtr *arr_num = new IntArrayPtr[row]; cout << " " << endl << " This program creates a 2D array of dynamic memory, fills it with user entered numbers, " << endl << " Then prints the array...
How to make an array without setting size?c++ cant figure this out without wanting to make...
How to make an array without setting size?c++ cant figure this out without wanting to make a vector or set a fixed size to the numbers. Prompt the user to ask how many numbers you wish to read. Then based on that fill out the elements of one dimensional array with integer numbers. Then sort the numbers and print the original and sorted numbers in ascending order side by side.
The anwsers that was given is not correct. I have tried but cant figure it out>...
The anwsers that was given is not correct. I have tried but cant figure it out> out You are evaluating a project for The Ultimate recreational tennis racket, guaranteed to correct that wimpy backhand. You estimate the sales price of The Ultimate to be $440 per unit and sales volume to be 1,000 units in year 1; 1,250 units in year 2; and 1,325 units in year 3. The project has a 3-year life. Variable costs amount to $245 per...
For Python, I cannot figure out why "and" is printing at the beginning of my list....
For Python, I cannot figure out why "and" is printing at the beginning of my list. Can someone help? listToPrint = [] while True: newWord = input("Enter a word to add to the list (prest return to stop adding words) > ") newWord == "": break else: listToPrint.append(newWord) for item in listToPrint[:-1]: print(item, end=', ') print('and', listToPrint[-1]) If I enter m, n, b to the list, it executes to and m, n, b
Why is my C code counter returning the wrong output? void removeLn(char *tPtr) { for (;...
Why is my C code counter returning the wrong output? void removeLn(char *tPtr) { for (; *tPtr != '\0'; tPtr++) { if (*tPtr == '\n') { *tPtr = '\0'; } } } This is a method I wrote that essentially replaces the \n in a text file with a null. int counter(FILE *filePtr) { char ln[length]; int counter = 0; while (fgets(ln, length, filePtr) != NULL) { char *r;    for (r = ln; *r != '\0';) { while (isspace(*r))...
this is my assignment for intro to java tha i could not figure out, my system...
this is my assignment for intro to java tha i could not figure out, my system just crashed wit a lot of errors. thank for your help Create a new Java class inside your project folder. The name of the class should be: TempConverter Note that this means you should have the following line at the top of your program: public class TempConverter Write a program that allows the user to convert a temperature given in degrees Celsius or Fahrenheit...
I have an unexpected indent with my python code. please find out whats wrong with my...
I have an unexpected indent with my python code. please find out whats wrong with my code and run it to show that it works here is the code : def main(): lis = inputData() customerType = convertAcct2String(lis[0]) bushCost = getBushCost(lis[0],int(lis[1],10)) flowerCost = getFlowerBedCost(int(lis[2],10),int(lis[3],10)) fertiCost = getFertilCost(int(lis[4],10)) totalCost = calculateBill(bushCost,fertiCost,flowerCost) printReciept(customerType,totalCost,bushCost,fertiCost,flowerCost) def inputData(): account, number_of_bushes,flower_bed_length,flower_bed_width,lawn_square_footage = input("Please enter values").split() return [account, number_of_bushes,flower_bed_length,flower_bed_width,lawn_square_footage] def convertAcct2String(accountType): if accountType== "P": return "Preferred" elif accountType == "R": return "Regular" elif accountType == "N": return...
I cannot figure out why my random name generator isn't producing the letter u or z....
I cannot figure out why my random name generator isn't producing the letter u or z. Can someone help me out? The language is java. import java.util.Random; public class BrandName {    public static void main(String[] args) {        Random random = new Random();        System.out.println("Brand Name Generator - Michael Wikstrom\n");        char odd[] = { 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y',       ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT