Programming and Problem Solving With C++
6th Edition
ISBN: 9781449694265
Author: Nell Dale
Publisher: Jones & Bartlett Learning
expand_more
expand_more
format_list_bulleted
Question
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
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:
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:…
Chapter 3 Solutions
Programming and Problem Solving With C++
Ch. 3 - Prob. 1PSCSCh. 3 - Prob. 1EPECh. 3 - Prob. 2EPECh. 3 - Prob. 3EPECh. 3 - Prob. 4EPECh. 3 - Prob. 5EPECh. 3 - Prob. 6EPECh. 3 - Prob. 7EPECh. 3 - Prob. 8EPECh. 3 - Prob. 9EPE
Ch. 3 - Prob. 10EPECh. 3 - Prob. 11EPECh. 3 - Prob. 12EPECh. 3 - Prob. 13EPECh. 3 - Prob. 14EPECh. 3 - Prob. 15EPECh. 3 - Prob. 16EPECh. 3 - Prob. 17EPECh. 3 - Prob. 18EPECh. 3 - Prob. 19EPECh. 3 - Prob. 20EPECh. 3 - Prob. 1PWECh. 3 - Prob. 2PWECh. 3 - Prob. 3PWECh. 3 - Prob. 4PWECh. 3 - Prob. 5PWECh. 3 - Prob. 6PWECh. 3 - Prob. 7PWECh. 3 - Prob. 8PWECh. 3 - Prob. 9PWECh. 3 - Prob. 10PWECh. 3 - Prob. 11PWECh. 3 - Prob. 12PWECh. 3 - Prob. 13PWECh. 3 - Prob. 14PWECh. 3 - Prob. 15PWECh. 3 - Prob. 1PPCh. 3 - Prob. 2PPCh. 3 - Prob. 3PPCh. 3 - Prob. 4PPCh. 3 - Prob. 5PPCh. 3 - Prob. 6PPCh. 3 - Prob. 7PPCh. 3 - Prob. 8PPCh. 3 - Prob. 1CSFCh. 3 - Prob. 2CSFCh. 3 - Prob. 3CSFCh. 3 - Prob. 4CSF
Knowledge Booster
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
- Using Codechum C++arrow_forwardWrite a C# program that plays a guessing game with the user. Your program should select a random number between 1 and 50 and then let the user try to guess it. The program should continue asking the user for a number until he guesses correctly. (See below for some tips on random numbers). CHALLENGE #1: Modify your program so that it only allows the user 10 guesses, and then declares them to be an inadequate guesser if they haven’t gotten it correct. Your program should output the random number chosen. CHALLENGE #2: Modify your program so that after they guess a number (or get declared inadequate, if you do Challenge #1) that it asks them if they want to play again, and responds accordingly. Some Random Number Generation HintsRandom rndNumber = new Random();Console.WriteLine(rndNumber.Next()); //random integerConsole.WriteLine(rndNumber.Next(101)); //random integer between 0 and 100Console.WriteLine(rndNumber.Next(10, 43)); //random integer between 10 and…arrow_forwardPlease help me with this. Please write it in c++. A simulation creates a model of a real-world situation, allowing us to introduce a variety of conditions and observe their effects. For instance, a flight simulator challenges a pilot to respond to varying conditions and measures how well the pilot responds. Simulation is frequently used to measure current business practices, such as the number of checkout lines in a grocery store or the number of tellers in a bank, so that management can determine the fewest number of employees required to meet customer needs. Airlines have been experimenting with different boarding procedures to shorten the entire boarding time, keep the flights on-time, reduce aisle congestion, and make the experience more pleasant for passengers and crew. A late-departing flight can cause a domino effect: the departure gate is tied up and cannot be used by other landing or departing flights, passengers on board the late flight may miss connecting flights and…arrow_forward
- In this c++ program you are asked to design a 2 x 2 x 2 Rubik's cube that is filled with numbers instead of colors. The cube, naturally, has six sides that are identified as follows: The front side is side 0 The right side is side 1 The backside side is side 2 The left side is side 3 The Up side is side 4 The bottom side is side 5 The squares on every side are initially filled with the same side index. This means that the four squares on the front side are filled with 0's, the four squares on the right side are filled with 1's, etc. You are allowed to move the cube in two directions only: Horizental move (H or h): The first row moves one step in four sides in this order (0 -> 1 -> 2 -> 3 -> 0) Vertical move (V or v): The left column moves one step in four sides in this order ( 0 -> 5 -> 2 -> 4 -> 0) The program accepts from the the user the number of moves he/she wants to make, accepts the sequence of desired moves as shown in the sample case below.…arrow_forwardI need help with this project that I've uploaded.arrow_forwardI'm currently trying to work on a modified problem from C++ Engineering and Science (Chapter 7.2, Problem 4e). I've compiled the project and tried to run it, only to get -858993460 as an output. I don't know if this is a technical problem with the program I'm using (visual studio) or if I just did the program incorrectly, but I've been having these issues since I've first downloaded visual studio, and IDK how to properly fix them. I'll provide the instructions below this (with the modifications in bold), as well as the code I have. All I ask is to get some pointers on how to fix the code. Declare and initialize an array named Resistances that holds the following values: 16, 27, 39, 56, 81. You must also create additional arrays named Current, Voltage, and Power, each with the same size as the Resistances array. Set up a for loop to allow the user to enter the ‘current’ values to be stored in the array named Current when the program is run. (This must be able to accept decimal numbers).…arrow_forward
- Can you help me with this program?In C++ The room contains n*n cubes (in rows and columns). Each cube is white or black. You can get out of a white cube by going in one of the four directions horizontally or vertically (but you can't go beyond the scope of the room). You can get out in a black cube, but you can't get out of it. There is a mouse and a piece of cheese in the room. The mouse is in a cube (0,0) - white, and the cheese in a cube (n-1, n-1) - black. The mouse can move from cube to cube according to the rules described above. Write a program that finds all the paths that can be moved to the cheese with the mouse and if it appears, display it with ‘*’. An example diagram of the task is shown in the figure: Operating instructions: Compose a recursive function path (int i, int j), receiving as parameters the coordinates of the current position of the mouse (initially 0.0, and then run with parameters (i-1, j), (i + 1, j), ( i, j-1) or (i, j + 1)).arrow_forwardUsing c++ Let's play a game of FizzBuzz! It works just like the popular childhood game "PopCorn", but with rules of math applied since math is fun, right? Just print out "Fizz" when the given number is divisible by 3, "Buzz" when it's divisible by 5, and "FizzBuzz" when it's divisible by both 3 and 5!arrow_forwardCODE USING C++ 3. Outsmarting the Guard by CodeChum Admin Great! Thanks to your help I've now reached the enemy's base. According to the plan, no one's supposedly going to see me but this guard has outsmarted me! He's big and mean and he's in here in front of me! For some reason though, although he looks scary on the outside, he's soft in the inside. He agreed to let me pass as long as I could compute the factorial of certain number. Please help me, Programmer! Instructions: In the code editor, you are given the main() code with the initial version of the factorial() function. To recap your basic math, the factorial of a number is basically the product of all the numbers from 1 up to that number. For example, the factorial of 5 is 120 because 1 x 2 x 3 x 4 x 5 = 120 and factorial of 3 is just 6 because 1 x 2 x 3 = 6. However, there's a special case and that is the factorial of 0 which is 1. The initial factorial() function lacks the recursive case. Fix it so the guard…arrow_forward
- Using C++ pleasearrow_forwardWork is in c++. All the details are in the pictures. This is NOT graded and this is NOT an essayarrow_forwardYou are in a store with a shopping list(a list of things you want to buy). Write pseudo code to describe how to use the shopping list to buy the items on the list. Note: please for C++ programming.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
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