Question

a. Create the logic for a program that calculates and displays the amount of money you...

a. Create the logic for a program that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed.

b. Modify the program in Exercise 3a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method.

c. Modify the program in Exercise 3b so that the main program also prompts the user for the interest rate and passes both the amount of money and the interest rate to the interest-calculating method. Write pseudocode. Submit only the final version of the program after you complete part c). Do not submit three different programs for this exercise.

Here's what I have so far...

Declarations
num balance
num PRINCIPAL = 5000
num INTEREST_RATE = 0.02
balance = PRINCIPAL * (1 + INTEREST_RATE)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

`Hey,

Note: In case of any queries, just comment in box I would be very happy to assist all your queries

a)
   amount = 5000
   rate = 2
   year = 1

   interest = calculateInterest(amount, rate, year);

   finalAmount = amount + interest

   ###### function ######
   calculateInterest(amount, rate, year):
       interest = (amount*rate*year)/100;
       return interest


b)
   amount <- enter amount
   rate = 2
   year = 1

   interest = calculateInterest(amount, rate, year);

   finalAmount = amount + interest

   ###### function ######
   calculateInterest(amount, rate, year):
       interest = (amount*rate*year)/100;
       return interest


c)

#include <iostream>
using namespace std;

// function defination
double calculateInterest(double amount, double rate, int year);

int main(){

   double amount, rate;
   int year = 1;

   cout<<"Enter amount: ";
   cin>>amount;

   cout<<"Enter rate: ";
   cin>>rate;

   // calling method
   double interest = calculateInterest(amount, rate, year);

   cout<<"Amount after 1 year: "<<(amount+interest)<<endl;

   return 0;
}

// function calculation
double calculateInterest(double amount, double rate, int year){

   return (amount*rate*year)/100.0;
}

→ secondweek → secondweek g++ simpleinterest.cpp → secondweek Sa.out Enter amount: 50000 Enter rate: 2 Amount after 1 year: 5

Kindly revert for any queries

Thanks.

Add a comment
Know the answer?
Add Answer to:
a. Create the logic for a program that calculates and displays the amount of money you...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • the author's pseudocode    it follows this template 3 Design the logic for a program for Nos...

    the author's pseudocode    it follows this template 3 Design the logic for a program for Nos Encanta Tu Interés credit card company that a) Allows the user to enter their name, credit card number, beginning balane and monthly interest rate b) For the next full year (12 months), 1. Outputs the month number and the balance at the beginning of the month 2. Allows the user to enter the amount of their payment, and the amount of their purchases for...

  • Create the Pseudocode logic for a program that helps a user to calculate one year of...

    Create the Pseudocode logic for a program that helps a user to calculate one year of simple interest. Create an appropriately named method to: input the amount the user is investing (principal) calculate one year of interest at a rate of 7% (the formula is quite simple, interest is the amount invested times 0.07) output the interest Be aware that any variables required by the method must be declared in the body of the method, not after immediately start like...

  • Write a Python program which simulates how a bank account works. (1) create a global constant...

    Write a Python program which simulates how a bank account works. (1) create a global constant INTEREST_RATE as the interest rate, which is assigned value 0.01. (2) create a global variable balance, which is initialized to 1000. (3) define a function named deposit which takes no parameter, it asks user to enter the amount of money that will be deposited into this account, then updates the global variable balance (which should increase by the amount of the deposit) and prints...

  • Modify the program below so it also calculates and displays the amount of money Package A...

    Modify the program below so it also calculates and displays the amount of money Package A customers would save if they purchased Package B or C, and the amount of money Package B customers would save if they purchased Package C. If there would be no savings, no message should be printed. import java.util.*; public class Lab2 { public static void main (String[] args) {    //scanner Scanner input = new Scanner(System.in);    //declarations int hours; char pack; double totalCharges...

  • Write a program that calculates the amount of money that you must invest In a savings...

    Write a program that calculates the amount of money that you must invest In a savings account at a given interest rate for a given number of years to have a certain dollar amount at me end of the period Y our program will ask the user for the amount the user wants to have at the end of the term (future value). the number of years the user plans to let the money stay in the account, and the...

  • Create a modular program using structured programming to store the amount of money a local store...

    Create a modular program using structured programming to store the amount of money a local store made in sales for each day of the past week. The user will be given the option to enter an amount for the next day, compute the average, find the highest amount, find the lowest amount, or print all the information including the daily sales with the average, highest, and lowest amount. When the user chooses an option to enter an amount for the...

  • Your program will ask the user to enter the amount of money they want to borrow,...

    Your program will ask the user to enter the amount of money they want to borrow, the interest rate, and the monthly payment amount. Your program will then determine how many months it will take to pay off that loan, what the final payment amount will be, and how much interest was paid over that time. If the monthly payment amount isn't high enough to pay off more than one month's interest, your program should notify the user what the...

  • Create a Java Program/Class named ComputeInterest to calculate compound interest. This can all be done entirely...

    Create a Java Program/Class named ComputeInterest to calculate compound interest. This can all be done entirely in the main() method. Create a double variable named currentBalance. Create a double variable named newBalance. Create a final double variable named INTEREST_RATE and assign 1.05 to it. Create a int variable named yearCount. Prompt for the "Number of years to invest" and store the input into the yearCount variable. Prompt for the "Amount to Invest" and store this in the currentBalance variable. Assign...

  • Can you send the code and the screenshot of it running? 1) Create a PYHW2 document...

    Can you send the code and the screenshot of it running? 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both flowchart and pseudocode forms for the following two functions: A. Write a Python function that receives a real number argument representing the sales amount for videos rented so far this month The function asks the user for the number...

  • Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate....

    Program Requirements ·         The program prompts the user to enter a loan amount and an interest rate. ·         The application calculates the interest amount and formats the loan amount, interest rate, and interest amount. Then, it displays the formatted results to the user. ·         The application prompts the user to continue. ·         The program stops prompting the user for values after taking 3 loan amounts. ·         The application calculates and displays the total loan and interest amount and ends the program Example Output Welcome to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT