where P is the principle in dollars), r is the interest rate (per year), and t i
ID: 3587887 • Letter: W
Question
where P is the principle in dollars), r is the interest rate (per year), and t is the time (in years). However, this time the user will input the time in days, not years, meaning you will have to perform a simple conversion. After reading in the time, divide the result by 365 and store it in a new variable called years. Use your new variable years for t in the equation, since the rate r is per year, not per day Specifications: The program should prompt the user for the principle and the time (in days), and calculate the interest based upon a 5.75% rate. Use-Enter principle: "as the prompt for the principle, and "Enter time (in days)as the prompt for the time. The interest and principle should be declared as floating point variables, and the interest rate should be defined as a constant. The time should be declared as an integer, and the new variable used to store the years should be a floating point value. Once you read in the information, print results of the calculation from days to years, in addition to the interest, both using a "3.2f" format. Please use the following variable names: interest-stores the earned interest I (floating point principle stores the initial principle P (floating point RATE-stores the high interest rate r (5.75%) (constant) time stores the time in days (integer) years stores the time t in years (floating point If you execute the program with the following underlined inputs, the results will be: > hw13. Enter principle: 4500.00 Enter time (in days): 300 In 0.82 years, the simple interest earned is: $212. 67Explanation / Answer
#include <stdio.h>
int main()
{
int time;
float years;
float RATE = 5.75;
float principle;
float interest;
printf("Enter principle: ");
scanf("%f", &principle);
printf("Enter time (in days): ");
scanf("%d", &time);
years = time/365.0;
interest = principle*years*RATE/100;
printf("In %.2f years, the simple interest earned is: $%.2f ", years, interest);
return 0;
}
Sample run:
Enter principle: 4500.00
Enter time (in days): 300
In 0.82 years, the simple interest earned is: $212.67
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.