Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.1, Problem 3STE
Suppose that you are still writing the same
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write code for below problem. The input below is just an example and you should implement independent from the input.
You will have an orthogonal triangle input from a file and you need to find the maximum sum of the numbers according to given rules below; 1. You will start from the top and move downwards to an adjacent number as in below. 2. You are only allowed to walk downwards and diagonally. 3. You can only walk over NON PRIME NUMBERS. 4. You have to reach at the end of the pyramid as much as possible. 5. You have to treat your input as pyramid. According to above rules the maximum sum of the numbers from top to bottom in below example is 24. *1 *8 4 2 *6 9 8 5 *9 3 As you can see this has several paths that fits the rule of NOT PRIME NUMBERS; 1>8>6>9, 1>4>6>9, 1>4>9>9 1 + 8 + 6 + 9 = 24. As you see 1, 8, 6, 9 are all NOT PRIME NUMBERS and walking over these yields the maximum sum.
Answer All the questions. Make sure your answers are short and precise.
You can use (Q1.txt or Ed) files to check your answers for Q1.
1. The phone numbers collected from questionnaire is a mess. Design a regular
expression to filter out those numbers that are stored in the standard format
"+00-0-0000-0000" from the file called "Q1.txt" and redirect the results to the
"cleaned.txt".
+61392144979
+61 3 9214 4778
+61-3-9214-4980
+66(2)51574430
+61-3-9285-7706
Note: Only +61-3-9214-4980 and +61-3-9285-7706 are the valid results.
The following is an old word puzzle: “Name a common word besides tremendous, stupendous, and horrendous that ends in ‘dous’”. IF you think about it for a while you may be able to solve it. But we are programmers and we don’t like to think. Also we can do something much better than just check to see if a word ends in dous. Create a program that will read the attached words.txt file. Ask the user for a string. Based on that string, output every word that ends in such a string. If there are no results say so. Try to ensure that the program does not have any errors based on the input from the user.
Chapter 6 Solutions
Problem Solving with C++ (9th Edition)
Ch. 6.1 - Prob. 1STECh. 6.1 - Prob. 2STECh. 6.1 - Suppose that you are still writing the same...Ch. 6.1 - Prob. 4STECh. 6.1 - Prob. 5STECh. 6.1 - Prob. 6STECh. 6.1 - Suppose bla is an object, dobedo is a member...Ch. 6.1 - Prob. 8STECh. 6.1 - Prob. 9STECh. 6.1 - A program has read half of the lines in a file....
Ch. 6.1 - Prob. 11STECh. 6.2 - Prob. 12STECh. 6.2 - Prob. 13STECh. 6.2 - Prob. 14STECh. 6.2 - What output will be sent to the stuff.dat when the...Ch. 6.2 - Prob. 16STECh. 6.2 - In formatting output, the following flag constants...Ch. 6.2 - Here is a code segment that reads input from...Ch. 6.2 - Prob. 19STECh. 6.2 - Write the definition for a void function called...Ch. 6.2 - (This exercise is for those who have studied the...Ch. 6.3 - Suppose c is a variable of type char. What is the...Ch. 6.3 - Suppose c is a variable of type char. What is the...Ch. 6.3 - Prob. 24STECh. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Suppose that the program described in Self-Test...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Prob. 29STECh. 6.3 - Define a function called copyLine that takes one...Ch. 6.3 - Prob. 31STECh. 6.3 - (This exercise is for those who have studied the...Ch. 6.3 - (This exercise is for those who have studied the...Ch. 6.3 - Suppose ins is a file input stream that has been...Ch. 6.3 - Write the definition for a void function called...Ch. 6.3 - Consider the following code (and assume that it is...Ch. 6.3 - Write some C++ code that will read a line of text...Ch. 6 - Write a program that will search a file of numbers...Ch. 6 - Write a program that takes its input from a file...Ch. 6 - a. Compute the median of a data file. The median...Ch. 6 - Write a program that takes its input from a file...Ch. 6 - Write a program that gives and takes advice on...Ch. 6 - Write a program that reads text from one file and...Ch. 6 - Prob. 7PCh. 6 - Write a program to generate personalized junk...Ch. 6 - Write a program to compute numeric grades for a...Ch. 6 - Enhance the program you wrote for Programming...Ch. 6 - Prob. 4PPCh. 6 - Write a program that will correct a C++ program...Ch. 6 - Write a program that allows the user to type in...Ch. 6 - This project is the same as Programming Project 6,...Ch. 6 - This program numbers the lines found in a text...Ch. 6 - Write a program that computes all of the following...Ch. 6 - The text file babynames2012.txt, which is included...Ch. 6 - To complete this problem you must have a computer...Ch. 6 - Write a program that prompts the user to input the...Ch. 6 - The following is an old word puzzle: Name a common...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
How many hello output lines does this program print?
Computer Systems: A Programmer's Perspective (3rd Edition)
public class MyClassT { public static void displayValue(T value) { System.out.println(value); } }
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
The classs________ are the statements that define the classs fields, properties, and methods. a. data agents b....
Starting out with Visual C# (4th Edition)
Write out definitions for the following fields:
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
What is a class specification file? What is a class implementation file?
Starting Out with C++ from Control Structures to Objects (8th Edition)
Why is the study of database technology important?
Database Concepts (7th 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
- Write a program (or use the interpreter) to open a file and print the length of the longest line in the file. (You can use the while loop example in section 4.3.1 as a guide to writing your program.) Paste your code into the text field.arrow_forwardMatlab Exercise: Create a wav file of your own voice by reading and recording the letters A, B, C and D. (You may use the application 'audacity' for this purpose Read the file from matlab. Find out the size of the matrix. Plot the wave file. Find out the length of recording from the plot. Play the sound file from matlab Work on the matrix so that the letters B and D will he audible on one track only while playing Work agaitn on the matrix so that the letters B and D are elitminated cumpletely from the wave file. In MATLABarrow_forwardDownload the text file, Random.txt, from the demo file folder on Canvas. This file contains a long list of random numbers. Copy the file to your hard drive (where the working directory of the IDE you use). Write a program that opens the file, reads all the numbers from the file, and calculates the following: 1. The number of numbers in the file 2. The sum of all the numbers in the file (a running total) 3. The average of all the numbers in the file Requirements: The program should display all numbers found in the file, and every twenty numbers in one line. Summarize the number of numbers found in the file, the sum of the numbers, and the average of the numbers in a table format. The average should be displayed in 2-digit in decimal. I mostly need help with the second part of requirements (1) It is C++arrow_forward
- We can read the file without opening it, Choose whether given statement is true or false. a. True b. Falsearrow_forwardHi, i need help with this program using Java. Write a program that reads the file AdventuresInWonderland.txt one line at a time and prints the count of each of the five vowels followed by a count of the consonants in the file. Coding requirements: Read the text from the file AdventuresInWonderland.txt. Use a single while loop to read the lines of the file. Use a single for loop to iterate over the characters in each line. Use a single switch statement to determine which counter to increment. Notes: The input may contain punctuation and digits as well as letters. Account for both uppercase and lowercase letters. Character.toLowerCase(ch) returns the lowercase character corresponding to ch(char ch). Character.toUpperCase(ch) returns the uppercase character corresponding to ch(char ch). Character.isLetter(ch) returns true when ch is an alphabetic letter Expected output: Vowels found: a: 324 e: 455 i: 251 o: 300 u: 109 Consonants: 2384 Example: If one creates a Scanner as…arrow_forwardAdd the ability to convert an entire message into Morse code, as well as the ability to handle a data file comprising numerous entries. Change your input validation code so that the user has an infinite number of opportunities to enter valid responses. Your program should run until the user selects the "quit" option from your menu. Add a menu option to provide the user the option of processing a data file. Add another way to exit the program. When your software starts, the menu should be the first item that appears. The menu format should be the same as in the Sample Output. Allow the user to make more menu selections until they select the option to exit. Before soliciting the user for a menu selection, always show the menu. Handle an incorrect menu option correctly. The user should have an infinite number of opportunities to enter a valid menu option. Validate the user's input for the number of words sent so that numbers less than one are not accepted. Allow the user an unlimited…arrow_forward
- I have a bit of code that is intended to read a file ("students.txt") and calculate the average, highest, and lowest scores from given information. (students.txt reads: " Mark Thompson 72.50James Taylor 100.00Daniel Price 80.2Busy Phillips 63.0 " ) This is the code I have: I have tweaked it to output the highest and lowest but I cannot get it to read the file. I have saved the file into the directory of the program but nothing seems to be working. I am also stumped on the formatting of the calculations. //////////////////////////////////////////// #include <iostream>#include <fstream>#include <cmath>#include <string>#include <iomanip>using namespace std; int main() { ifstream inFile; // This is a declaration of the inFile that holds all the gradesstring fileName; // This is the filename that the user will enterconst int min = 63.0; // This is a constant min used to find the lowest scoreconst int max = 100.0; // This is the constant max used to find the…arrow_forwardI have a bit of code that is intended to read a file ("students.txt") and calculate the average, highest, and lowest scores from given information.(students.txt reads: " Mark Thompson 72.50James Taylor 100.00Daniel Price 80.2Busy Phillips 63.0 " )This is the code I have:I have tweaked it to output the highest and lowest but I cannot get it to read the file. I have saved the file into the directory of the program but nothing seems to be working. I am also stumped on the formatting of the calculations. //////////////////////////////////////////// #include <iostream>#include <fstream>#include <cmath>#include <string>#include <iomanip>using namespace std; int main() { ifstream inFile; // This is a declaration of the inFile that holds all the gradesstring fileName; // This is the filename that the user will enterconst int min = 63.0; // This is a constant min used to find the lowest scoreconst int max = 100.0; // This is the constant max used to find the…arrow_forwardThis is a java assignment. I have attached it as an image file.arrow_forward
- Find the attached file.arrow_forwardUse loop to solve this python program and use Error handling:IOError (File not found)arrow_forwardI have a bit of code that is intended to read a file ("students.txt") and calculate the average, highest, and lowest scores from given information. (students.txt reads: " Mark Thompson 72.50James Taylor 100.00Daniel Price 80.2Busy Phillips 63.0 " ) I have tweaked it to output the highest and lowest but I cannot get it to read the file. I have saved the file into the directory of the program but nothing seems to be working. I am also stumped on the formatting of the calculations. If nothing else, since I cannot seem to get the file to open, I need these values included as well as the commands to calculate the noted answers (average, highest, and lowest) in the output. This is the code that I have so far: //////////////////////////////////////////// #include <iostream>#include <fstream>#include <cmath>#include <string>#include <iomanip>using namespace std; int main() { ifstream inFile; // This is a declaration of the inFile that holds all the gradesstring…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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C - File I/O; Author: Tutorials Point (India) Ltd.;https://www.youtube.com/watch?v=cEfuwpbGi1k;License: Standard YouTube License, CC-BY
file handling functions in c | fprintf, fscanf, fread, fwrite |; Author: Education 4u;https://www.youtube.com/watch?v=aqeXS1bJihA;License: Standard Youtube License