Programming and Problem Solving with C++: Comprehensive
Programming and Problem Solving with C++: Comprehensive
6th Edition
ISBN: 9781284076592
Author: Dale, Nell
Publisher: JONES+BART
bartleby

Videos

Question
Book Icon
Chapter 3, Problem 1PSCS
Program Plan Intro

To modify the case study program to print interest rate without precision loss and restrict monthly payment to two decimal places.

Expert Solution & Answer
Check Mark

Explanation of Solution

Following is the modified program(changes are highlighted in grey):

/*
Put code from book
    .........
    .........
    .........
    
    
*/
//main function
intmain()
{
/*
    Put code from book
    .........
    .........
    .........
    
    
    */
//modifed code
cout<<"For a loan amount of "<<LOAN_AMOUNT<<" with an interest of "<<YEARLY_INTEREST<<" and a "<<NUMBER_OF_YEARS<<fixed<<setprecision(2)<<" year mortgage."<<endl;
cout<<fixed<<setprecision(2)<<" your monthly payment are $"<<payment<<"."<<endl;
//exiting from program
return 0; 
}

Explanation:

The setprecision(2) along with fixed is used to fix the precision value to two decimal point. Remove the setprecision(2) along with fixed from the first cout statement.Put the setprecision(2) along with fixed from the start of second cout statement.

Sample Output:

Programming and Problem Solving with C++: Comprehensive, Chapter 3, Problem 1PSCS

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!
Students have asked these similar questions
I have attached my code, under I want you to show me how to enhance it and make it more cooler and better in graphics with following the instructions.
Using R language
Using R language
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Principles of Information Systems (MindTap Course...
Computer Science
ISBN:9781285867168
Author:Ralph Stair, George Reynolds
Publisher:Cengage Learning
Structured Chart; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=vdUO-sGA1DA;License: Standard YouTube License, CC-BY
Introduction to Structure Charts; Author: Christopher Kalodikis;https://www.youtube.com/watch?v=QN2bjNplGlQ;License: Standard Youtube License