Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 4, Problem 5PP
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Three rectangles have to be drawn in a blackboard. Get the x and y coordinate values of the three rectangles from the person who is going to draw the rectangle, Write a function to find the area of these
rectangles and print it in the calling function.
create a file in c++.
In this lab, you will replace the existing functions with more flexible ones, and you will add additional functions to perform modular tasks.
The "old" functions for displaying "hello", "goodbye", "invalid selection" and "invalid input" all do basically the same thing. They simply display a message to the user. Replace the old functions with a new function called displayMessage. The function should take a string argument, and display it.
void displayMessage(string); //prototype
The old function for displaying the menu would be more useful if it also returned the menu selection. Replace the old function with a new one called getMenuSelection that will return the menu selection as a char variable. Make sure to use the function result when you call it (assignment, display, use in expression, another function call, etc.).
char getMenuSelection(); //prototype
Wouldn't it be nice to check the menu selection for an invalid input? How about checking to see if the exit…
Change each one of these questions to now work using a function.  decide what the name of the function of each should be, how many parameters are required and what value needs to be returned. You’re no longer required to solve the problem - try to re-manage your code to be a function.
Write a program that uses input to prompt a user for their name and then welcomes
them.
Enter your name: Chuck
Hello Chuck
Chapter 4 Solutions
Absolute C++
Ch. 4 - Write a program that converts from 24-hour...Ch. 4 - The area of an arbitrary triangle can be using the...Ch. 4 - Write a program that tells what coins to give out...Ch. 4 - Write a program that will read in a length in feet...Ch. 4 - Write a program like that of the previous exercise...Ch. 4 - (You should do the previous two programming...Ch. 4 - Write a program that will read a weight in pounds...Ch. 4 - Write a program like that of the previous exercise...Ch. 4 - (You should do the previous two programming...Ch. 4 - (You should do Programming Projects 4.6 and 4.9...
Ch. 4 - You are a contestant on a game show and have won a...Ch. 4 - In the land of Puzzlevania, Aaron, Bob, and...Ch. 4 - You would like to know how fast you can run in...Ch. 4 - Your time machine is capable of going forward in...Ch. 4 - Write a function named convertToLowestTerms that...Ch. 4 - Consider a text file named scores. txt that...Ch. 4 - Given the scores . txt file described in...Ch. 4 - Write a function named sort that takes three...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
True or False: An object of a superclass can access members declared in a subclass.
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Write a program to read in three nonnegative integers from the keyboard. Display the integers in increasing ord...
Java: An Introduction to Problem Solving and Programming (8th Edition)
Which of the following activities require real-time processing? a. Printing mailing labels b. Playing a compute...
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Determine the resultant internal normal force, shear force, and bending moment at point C in the beam.
Mechanics of Materials (10th Edition)
Assume a telephone signal travels through a cable at two-thirds the speed of light. How long does it take the s...
Electric Circuits. (11th Edition)
Use the following tables for your answers to questions 3.7 through 3.51 : PET_OWNER (OwnerID, OwnerLasst Name, ...
Database Concepts (8th Edition)
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
- Some of the earliest computer games developed were Interactive Fiction games, in which the user’s environment is described in text, and the user makes choices using text commands. In this problem and the next one, we’ll be developing a very simple text-based adventure game. Every choice in this game will have exactly three options, so we can write a function that works for any of them. Write a function selection(text, optionA, optionB, optionC), that takes in four string values. text is a string representing a prompt in a text adventure game, and optionA, optionB, and optionC are strings representing the three possible options. The function should print out the text, and then print out the options (label them with A., B., and C.). Next, the input() function should be used to prompt the user to choose A, B, or C. Then the function should return (not print) the one character string that represents the user’s choice: 'A', 'B', or 'C'. If the user does not choose one of those…arrow_forward#include #include #include #include using namespace std; // four function declarations int main() { int id nullptr; string* name = nullptr; int* score = nullptr; char filename [20]; cout> filename; int count = readDataFromFile(filename, &id, &name, &score); cout << "count : " << count << endl; printData(id, name, score, count); int max; findMax (score, &max, count); printMaxList (id, name, score, count, max); return 0; Enter filename: student. txt Students List 108927 101981 102888 100738 100892 102893 109189 107182 106627 102930 108992 109281 104244 105566 102871 107889 Alice 80 Paul 92 86 70 Ruth 89 John 91 Tammy 95 Jenny 72 Amy 95 77 71 Cindy Robert Brian Hailey Jake 88 69 95 Sandy Chris Angel 82 Sue 93 *** Max score : 95 Students with max score 109189 95 } 106627 95 // four function definitions (readDataFromFile, printData, findMax, printMaxList) 105566 Chris 95 Tammy Amyarrow_forwardMust show it in Python: Please show step by step with comments. Please show it in simplest form. Input and Output must match with the Question Please go through the Question very carefully.arrow_forward
- Complete the process_name() function that takes a single string parameter name. You can assume that the name will always be in the format first name surname with a single space character between the first name and the surname. The function returns a string consisting of the first letter of the first name followed by the first three letters of the surname. All of the characters in the returned string should be in lowercase. Some examples of the function being used are shown below: For example: Test Result print(process_name("Damir Azhar")) dazh print(process_name("Ann Cameron")) acam Answer: (penalty regime: 0 %) Reset answer 1v def process_name (name): 2arrow_forwardLook carefully at the code for your functions read_age and read_siblings. Can you see a pattern? Each of these functions prompts the user until they supply a valid integer, which is then returned. In fact, the only differences between the two functions are the prompt string for the user and a few variable names. When we find very similar blocks of code like this in a program, we should look for a single function that can do both tasks. So ... how can we generalise these functions into a single function that can be used (in two separate calls) to read both the age and the number of siblings while still printing a suitab prompt? Add a new function to your program called read_int(prompt) that takes a prompt string as input. It should use that string to prompt the user for a valid integer and then return it. Once you have done this, delete the functions read_age and read_siblings from your program and replace all calls to them with appropriate calls to you new read_int(prompt) function so…arrow_forward*DONOT USE CHATGPT, please put comments so i can understand. It’s a C language program with algorithm.arrow_forward
- Add a function to get the CPI values from the user and validate that they are greater than 0. 1. Declare and implement a void function called getCPIValues that takes two float reference parameters for the old_cpi and new_cpi. 2. Move the code that reads in the old_cpi and new_cpi into this function. 3. Add a do-while loop that validates the input, making sure that the old_cpi and new_cpi are valid values. + if there is an input error, print "Error: CPI values must be greater than 0." and try to get data again. 4. Replace the code that was moved with a call to this new function. - Add an array to accumulate the computed inflation rates 1. Declare a constant called MAX_RATES and set it to 20. 2. Declare an array of double values having size MAX_RATES that will be used to accumulate the computed inflation rates. 3. Add code to main that inserts the computed inflation rate into the next position in the array. 4. Be careful to make sure the program does not overflow the array. - Add a…arrow_forwardHelp.arrow_forwardTask 2: The formula for the area, A, of a triangle with sides of length a, b, and c is V[s(s – a)(s – b)(s – c)] A = Where (a + b + c) s = Write, test, and execute a function that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of s and [s(s - a)(s - b)(s - c)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A = -1. The value of A should be returned by the function. Test the function by passing various data to it and verifying the returned value.arrow_forward
- Write a C++ program to carry out the operations of a simple calculator that accepts whole numbers and decimals. • Your user must be able to use the calculator without having to restart cach time. • Also, include functions to: add, subtract, and convert vectors from complex form to polar form and vice versa. Include a function that displays a menu of options. All mathematical operators are to be included.arrow_forwardPython questionarrow_forwardComplete and fix this code C program ONLY. Please finish the function printMap and updateMap to make the maze project work.Your code should move the cursor to the starting point located at the first 0 from the topand left border, and then use w, a, s, or d keys to control it to move to E. When E isreached, your code will print a message on the screen “Maze solved!!!”Please notice that part of the code is already provided, and you need to understand the code and finish it by sending screenshotsarrow_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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
What Are Data Types?; Author: Jabrils;https://www.youtube.com/watch?v=A37-3lflh8I;License: Standard YouTube License, CC-BY
Data Types; Author: CS50;https://www.youtube.com/watch?v=Fc9htmvVZ9U;License: Standard Youtube License