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
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.
Using the C++ programming language.
Hello, welcome to the Code Blasters code-writing competition! So, let's start with the
exercise first.
The chef is a master of the number two game, and the chef wants you to play this
game with him as he has nothing to do due to the closure of COVID-19.
The game is simple chef will give you two numbers (say a and b) and you need to tell
that the two given numbers can be equal after performing the given tasks.
Increase by 1 OR
reducing b by 1
Input:
2
57
10000 5000
Output:
YES
NO
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
- I am having trouble running the code, it says there are a lot of errors and I am not sure I am even running it right. How would I go about running the code and fixing the errors in C++arrow_forwardAnswer in C++ only Did you know that a beautiful gold triangle was introduced to India in the early 13th century? Well, I'm referring to the famous South Asian candy, Samosa. I think it's hard to write it while thinking about Samosa, especially if you're so hungry right now; so let's not get into any recipe or food game. You have N boxes in Samosas, where each box is a cube. To pack the box, you need to use a rubber band (pseudo-circular, elastic band) by placing it next to the box (4 faces of a cube). The rubber band A (R1, R2) has an initial radius of R1 and can be expanded in size up to R2 without breaking. You can pack a cubic box of side length L using a 4 * L round rubber band (see Notes for clarity). Given the M- band bands and their first radius and the main radius, we need to match (provide) some rubber bands and boxes. The box needs at least one rubber band to pack and of course, each rubber band can be used to pack at least one box. Find the maximum number of boxes we can…arrow_forwardC++ 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: ...arrow_forward
- Write 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.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_forwardIn 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_forward
- You are to design a game that can be either single-player or multi-player (no AI required). Some example games are: • Standard card games • Connect four • Checkers • Oregon Trail • A game of your own creation! You should provide detailed instructions on what the code’s intended operation is. You must give sample input that tests the code rigorously for different scenarios. In C++ please.arrow_forwardI am trying to complete this assignment in Java.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_forward
- Write a c++ program for You are burning some music CDs for a party. You've arranged a list of songs in the order in which you want to play them. However, you would like to maximize your use of space on the CD, which holds 80 minutes of music. So, you want to figure out the total time for a group of songs and see how well they fit. Write and design a java program to help you do this. The data are on the file songs.dat. The time is entered as seconds. For example, if a song takes 7 minutes and 42 seconds to play, the data entered in the data file for that songs would be 462.After all the data has been read, the application should print a message indicating the time remaining on the CD.The output should be in the form of a table with columns and headings written on a file. For example:Song Song Time Total TimeNumber Minutes Seconds Minutes Seconds------- ------- ------- ------- -------1 5 10 5 102 7 42 12 523 4 19 17 114 4 33 21 445 10 27 32 116 8 55 41 67 5 0 46 6There are 58 minutes and…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_forwardOne of the football fans heard that one of the most outstanding players, Mesut Ozil, has decided to play in Turkey. That guy wanted to go to the airport to welcome him. The fan wanted to find out how many football fans will be there. To do that, it is needed to have a new computer program, and you should implement it. The fan realized that a few factors affect the decision to go to the airport or not. The rules are given below: Adanaspor, Besiktas, and Fenerbahce fans are willing to go to the airport. If the age is lower than 18 or higher than 55, they prefer to stay at home. If the distance to the airport is further than 10 km and closer than 50 km, they want to go to see him. When the weather condition is starting with "S", fans want to go to the airport. Your program should read all the inputs, supported team, age, distance, and weather condition, in this order. Supported teams can only be Adanaspor, Besiktas, Fenerbahce, Galatasaray, and Trabzonspor Weather condition can only be…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