C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
8th Edition
ISBN: 9781337684392
Author: Malik, D. S.
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 5, Problem 11PE
The program in the
Expert Solution & Answer
Trending nowThis is a popular solution!
Students have asked these similar questions
The course grades of 75 students
from 5 courses are given in the form
of a table. Write an algorithm that
writes "cannot be entered" for those
with an average of less than 40
course grades, and "can be entered"
for 40 and above. (Please explain
everything the program in details and
please check whether the program
runs or not by using q-basic64. 01:44
Three numbersa. Write a program that reads three numbers and prints “all the same” if they are allthe same, “all different” if they are all different, and “neither” otherwise.b. Write a program that reads three numbers and prints “increasing” if they are inincreasing order, “decreasing” if they are in decreasing order, and “neither”otherwise. Here, “increasing” means “strictly increasing”, with each value largerthan its predecessor. The sequence 3 4 4 would not be considered increasing.c. Repeat part b. but before reading the numbers, ask the user whetherincreasing/decreasing should be “strict” or “lenient”. In lenient mode, thesequence 3 4 4 is increasing and the sequence 4 4 4 is both increasing anddecreasing
Homework write a program that will add the terms of an infinite geometric series. The program should read the first term (a) and the common ratio (r) for the series. It should the compute the sum in two ways: by formula (s=a/1-r), and by adding the individual terms until the answer agrees with the formula to 7 significant digits. The print the formula answer, the answer found by adding terms, and the number of terms that were added. Print the sums to at least ten places. Verify input with a while loop. Two real values are equal to n significant digits if the following condition is true: |a-b|<|a*10^-n|
HELP ME FIX MY CODE comment in the picture.
#include <iostream>#include <cmath>using namespace std;
int main(){ int i = 1;double a, b, r, number, sumbyformula, sum2;cout<<"Enter a value of first term a: ";cin>>a;cout<<"Enter a value of ratio r: ";cin>>r;// Loop -1<r<1while(r>=1 and r<=-1){cout<< "Enter the number between -1 and 1…
Chapter 5 Solutions
C++ Programming: From Problem Analysis To Program Design, Loose-leaf Version
Ch. 5 - Prob. 1TFCh. 5 - What type of loop, such as counter control or...Ch. 5 - Prob. 20SACh. 5 - Prob. 27SACh. 5 - Prob. 40SACh. 5 - Prob. 45SACh. 5 - Write a program that prompts the user to input an...Ch. 5 - Write a program that prompts the user to input a...Ch. 5 - Write a program that uses while loops to perform...Ch. 5 - Redo Programming Exercise 8 using dowhile loops.
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
- Homework write a program that will add the terms of an infinite geometric series. The program should read the first term (a) and the common ratio (r) for the series. It should the compute the sum in two ways: by formula (s=a/1-r), and by adding the individual terms until the answer agrees with the formula to 7 significant digits. The print the formula answer, the answer found by adding terms, and the number of terms that were added. Print the sums to at least ten places. Verify input with a while loop. Two real values are equal to n significant digits if the following condition is true: |a-b|<|a*10^-n| Wrong test - this won't work if r is very near one. Try a=2, r=.99999 With smaller values of r, it is asking for too much precision. With a=2,r=.99, it is getting 10 significant digits. HELP ME FIX CODE. PLEASE USE MY CODE FIX #include <iostream>#include <cmath>using namespace std; int main(){ //declare variables int terms; double a, r, number, sumbyformula, sum2;…arrow_forward6. A palindrome is a number or text phrase that reads the same backwards or forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that reads a 5 digit integer and determines whether it is a palindrome. Hint: One way to do this is to use division (/) and modulus (%) operators to separate the number into individual digits.arrow_forwardThe Café Noir Coffee Shop wants some market research on its customers. When a customer places an order, a clerk asks for the customer’s zip code and age. The clerk enters that data as well as the number of items the customer orders. The program operates continuously until the clerk enters a 0 for zip code at the end of the day. When the clerk enters an invalid zip code (more than 5 digits) or an invalid age (defined as less than 10 or more than 110), the program reprompts the clerk continuously. When the clerk enters fewer than 1 or more than 12 items, the program reprompts the clerk two more times. If the clerk enters a high value on the third attempt, the program accepts the high value, but if the clerk enters a negative value onthe third attempt, an error message is displayed and the order is not counted. At the end of the program, display a count of the number of items ordered by customers from the same zip code as the coffee shop (54984), and a count from other zip codes. Also…arrow_forward
- TASK " Write a program that grades students' exam. The exam has 20 multiple choice questions. Here are the correct answers: 1- A 6- B 11-C 16- D 2- A 7- B 12- C 17- D 3- А 8- В 13-С 18- D 4- А 9- В 14- С 19- D 5- A 10-B 15- C 20- D "A student must correctly answer 15 of the 20 questions to pass the exam. " Write a class named StudentExam that holds the correct answers to the exam in an array. TASK (CONT.) " The class should also have an array that holds the student's answers. The class also should have the following methods: I passed. Returns true if the student passed the exam, or false if the student failed " totalCorrect. Returns the total number of correctly answered questions I totallncorrect. Returns the total number of incorrectly answered questions " questionsMissed. An int array containing the question numbers of the questions that the student missed. 1 On another class, ask the student to enter his name, take his answers and display the results returned from the StudentExam…arrow_forwardFind the first 10 square numbers that are greater than Long.MAX_VALUE. A square number is a number in the form of n2. For example, 4, 9,and 16 are square numbers. Find an efficient approach to run your program fast.arrow_forwardThis assignment is to modify the rock-paper-scissors game f. As before, each of twoplayers enters P, R, or S. The program will announce the winner and the basis for determining thewinner: Paper covers rock, Rock breaks scissors, Scissors cut paper, or Draw, nobody wins.The players must be able to enter either upper-case or lower-case letters.There are two major changes. First, you will need to create an enumeration called choices thathas three values, ROCK, PAPER, and SCISSORS. You should then use the typedef keyword to createa type for this enumeration named Choice. When you read the player's choice in your getThrowfunction, you will need to return a Choice for that player rather than a char as before. This makesit so that the only part of the program that deals with character type variables is the getThrowfunction; the rest of your program should always use variables of the enumerated Choice type. Thismeans that your checkWinner function will take two Choices as parameters…arrow_forward
- The greatest common divisor (gcd) of the two integers 4 and 2 is 2. The greatest common divisor of the two integers 16 and 24 is 8. How would you write this program to find the greatest common divisor?arrow_forward1. Write a program that asks the user to enter three names, and then displays the names sorted alphabetically in descending order. For example, if the user entered "Charlie", “Leslie", and "Andy", the program would display: Leslie Charlie Andy Note that these three names are just an example. The names could be any words. 2. Write a program that asks the user to enter a year, and then displays whether that year is a leap year or not. Note that a year is a leap year if the year is a multiple of 400, or it is a multiple of 4 and not a multiple of 100. 3. Write a program to repeatedly read integers from the standard input until it reads -1 and exits. For each number before -1, if it is positive and odd, do the following: • Output a triangle like the one below with the integer being the width of the triangle's bottom or the number of asterisks of the bottom row. For instance, if the integer is 7, you would display the triangle below: *** ***** Or if the integer is not positive or not odd,…arrow_forwardPart 1: Complete the survey. Part 2: Peek-a-boo is a fun game that little kids like to play. To simulate this game on the computer, write a program that will generate a random number between 1 and 4. Then, will print to the screen the animal name associated to that number. The animal names used will be: pig when a 1 is generated cow when a 2 is generated chicken when a 3 is generated horse when a 4 is generated If your program generates a 3, the output will be: chicken The player will then enter a 1 if they would like to play again or anything else to exit the program. If the player enters "1 1 1 0", the output will be: horse chicken cow horse For coding simplicity, follow each output animal by a space, even the last one. Hint: To make testing easier, seed your random number generator with 0.arrow_forward
- IN PYTHON PLEASE AND FLOWCHART DRAWING COMPUTERIZED PLEASE!! In many businesses across the country, people are buying food and goods using cash. Whenever a purchase is made with cash, it is usual that change must be back to the customer. Business point of sales software help to ensure that the correct change is return to a customer by providing detailed information of the change that should be returned to the customer. using the fewest number of bills and coins. In this assignment, you are asked to design and implement a program that writes out what bills (ones, fives, tens, twenties) and coins (pennies, nickels, dimes, and quarters) that should be returned to the customer given two inputs from the user: A total cost of a sale. The amount that was paid by the customer. Ensure that your output is grammatically correct. If the customer does not provide adequate payment, you should print the following statement, the program should end. Did not receive enough cash from the customer.…arrow_forwardTransient PopulationPopulations are affected by the birth and death rate, as well as the number of people who move in and out each year. The birth rate is the percentage increase of the population due to births and the death rate is the percentage decrease of the population due to deaths. Write a program that displays the size of a population for any number of years. The program should ask for the following data: The starting size of a population P The annual birth rate (as a percentage of the population expressed as a fraction in decimal form)B The annual death rate (as a percentage of the population expressed as a fraction in decimal form)D The average annual number of people who have arrived A The average annual number of people who have moved away M The number of years to display nYears Write a function that calculates the size of the population after a year. To calculate the new population after one year, this function should use the formulaN = P + BP - DP + A - Mwhere N is the…arrow_forwardA student took four quizzes in a term and would like to compute their average. He also would like to know what will be the remarks. Follow the range of grades and its equivalent remarks, and then fill-up the table below:100-95 - Excellent94-90 – Very Satisfactory89-85 - Satisfactory84-80 - Fine79-75 - Fair74 and below – Poor . What statement in the program that determines that the average is passing? 2. What was the condition applied to satisfy the requirement?3. What have you observed in using if-else statement in this program?4. What have you observed in using nested if statement in this program?arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Python Tutorial #10; Math Functions in Python; Author: Art of Engineer;https://www.youtube.com/watch?v=OviXsGf4qmY;License: Standard YouTube License, CC-BY