Programming and Problem Solving With C++
Programming and Problem Solving With C++
6th Edition
ISBN: 9781449694265
Author: Nell Dale
Publisher: Jones & Bartlett Learning
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++, 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
How would you create a card game in C# that is essentially higher or lower? There is one card flipped to show the value and 10 showing the back of the card. You continue down the line until you guess wrong.
C++ coding In order to paint a wall that has a number of windows, we want to know its area. Each window has a size of 2 ft by 3 ft. Write a program that reads the width and height of the wall and the number of windows, using the prompts Wall width: Wall height: Number of windows: Then print the area with two digits after the decimal point: Area: ...
Part 2 only please!!! C++ Language.   Part 1: As an avid Monopoly player, I've often wondered what the most common dice rolls are when you roll 2 6-sided dice and sum the result.  To answer this question experimentally, write a program that asks the user how many trials they would like to run.  Then, simulate the roll of 2 six-sided dice using rand() repeatedly, according to how many trials the user wanted to run.  Finally, report the percentage of how many of the trials yielded a given sum for each of the possible sums from 2 to 12.  Here is an example run: Each time the result for 1 die comes out and it’s 1 assign it the value of 1/num throws How many times do you want to throw a pair of six-sided dice? >  1000 The distribution of results from the 1000 trials is: (the numbers below are not actually correct) 2:            .01 3:            .04 4:            .50 5:            .10 6:            .20 7:            .30 8:            .10 9:            .10 10:          .50 11:…
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.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
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