Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 6.2, Problem 21STE
(This exercise is for those who have studied the optional section entitled “File Names as Input.”) Suppose you are given the following string variable declaration and input Statement:
#include <iostream>
using namespace std;
// ... char name[21];
cout >> name;
Suppose this code segment is embedded in a correct
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
2. Test Scores
File: test_scores.py
Write pseudocode for the main() part of a program that asks the user to enter 4 test scores between 0 and 100, then displays a JCU grade for each score and also the average test score.
When you have written the pseudocode for main, implement your solution in Python code and test it with a range of meaningful data.
Remember that we've done the JCU grades question before, so copy your function from that practical code file.
Sample Output
Score: 3
Score: 50.5
Score: 66
Score: 100
Score 3.0, which is N
Score 50.5, which is P
Score 66.0, which is C
Score 100.0, which is HD
The average score was 54.875
Enhancements
When you have that working...
We asked for 4 scores. Have a look at your code... did you use 4 as a numeric literal or a constant?Change 4 to 3... Did you have to change the program in more than one place?If so, then you've missed one of the things we've taught...As a strong guideline: if you need to use the same literal more than once, you…
Hello good afternoon,
Write a C++ program that reads data from an input file, takes the data and computes student grades for an assignment by converting the raw score to a percentage given each student's score and the total points. The final score must be rounded up to the nearest whole value using the ceil function in the header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to compute and print the percentage as well as "Excellent" if the grade is greater than 90, "Well Done" if the grade is greater than 80, "Good" if the grade is greater than 70, "Need Improvement" if the grade is greater than or equal to 60, and "Fail" if the grade is less than 50. The main function is responsible for reading the input file and passing the appropriate arguments to your functions.
Exercise #2 Frequency Analysis:
One of the oldest approaches to breaking a code is to perform a frequency count of letters.
Write a C++ program to perform a frequency count by reading the text from a file (code.txt). Your
program should output how many A's are there in the text, how many B's are there,
and so on. Note that the program will not make any distinction between uppercase
and lowercase letters. It will output the results to the screen and in a text file (count.txt)
Sample output (for code.txt):
A: 3
B: 3
C: 23
D: 13
E: 41
F: 4
G: 9
H: 15
1:44
J: 1
K: 0
L: 7
M: 9
N: 33
O: 16
P: 4
Q:0
R: 22
S: 24
T: 27
U: 8
V: 5
W: 1
X: 0
Y: 4
Z: 0
Chapter 6 Solutions
Problem Solving with C++ (10th 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
Briefly describe what each of the following statements does. file.seekp(100L, ios::beg); file.seekp(-10L, ios::...
Starting Out with C++: Early Objects
Why is it necessary to introduce some methods and documentation from plan-based approaches when scaling agile m...
Software Engineering (10th Edition)
Given the following fragment that purports to convert from degrees Celsius to degrees Fahrenheit, answer the fo...
Absolute Java (6th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
What is the purpose of an objects sizing handles?
Starting Out With Visual Basic (7th Edition)
Is it possible to pass initialization values to the constructor when you create an object? If so, how?
Starting out with Visual C# (4th 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
- void change( int a[]) , the compiler converts the parameter to: Select one: a. int *const a b. int &a; c. int a d. const int a; c++arrow_forwardIn c++: Bracket Matcher Given a text file, your program will determine if all the parentheses, curly braces, and square brackets match, and are nested appropriately. Your program should work for mathematical formulas and most computer programs. Your program should read in the characters from the file, one at a time, but ignore all characters except for the following: { } ( ) [ ] Your program should use the provided IntStack implementation (IntStack.h and IntStack.cpp). The general algorithm is to use the stack to store the opening unmatched brackets as they are encountered in the input. When a closing bracket is encountered, check it against the one on top of the stack (pop it off)--make sure it matches. When you are finished, if all the brackets match then there should be no unmatched brackets left on the stack. (Note: it might be easier to store the expected closing character on the stack when an opening bracket is encountered; this simplifies the matching when a closing bracket…arrow_forwardC++ Write a program which counts and displays the number of characters (including blanks) in its own source code file. [i have already asked this question but you gave wrong answer ... plz give correct answer i have to prepare for my exams.. ]arrow_forward
- TEST INPUT: I Love C Programming Write a program to replace all the vowels with empty spaces in a sentence. For example- if your input string is "Hello World!!", your output string should be "H II W rld!!" [The sentence must be stored in a dynamically allocated memory.]arrow_forwardC++ Write a program which counts and displays the number of characters (including blanks) in its own source code file. [i have already asked this question but get the wrong answer from your side ... plz give the 100% correct answer this time I have to prepare for my exams.. ]arrow_forwardQ1/ Write a program in C++ by using function to remove the spaces before and after the entered text, such as AAAHello word AAA Note: This symbol A denotes a single spacearrow_forward
- tory O The Assignment Assume you're trying to build an e-mailing list by analyzing some random text data pulled from the internet for your unethical Email Spam Business. Your task is to write a C++ program that asks the user to enter a file for processing. You should then test each "word" in the file to determine if the "word" is an email address. The program then outputs, to a separate file called results.out, one per line, every "real" e-mail address contained inside the file as it runs across them. across them. For this assignment, our "words" are white space delimited strings within the file, and if a "word" has an embedded commercial at sign (@) inside it, we shall consider it a possible e-mail address. All possible email addresses will need to be further processed to determine "real" email addresses contained in the data file. To determine if it a "real" email address and worthy of your company's spam mailing list, you will need to process the emails a little further. • First,…arrow_forwardC PROGRAM Write a program that asks the user values for the coefficient A,B, and C in the quadratic equation Ax^2 + Bx + C= 0, and then prints the solution/s of the equation (if there is/are any) For this problem, you need to include the following header file: math.h So that you can use the C library function sqrt() The function sqrt() computes the square root of a value (in double) Use #include <stdio.h>arrow_forwardC++ The file text.txt contains a sentence text written in all small letters and does not have any punctuation marks, no numbers, no symbols except for spaces. You are required to write a program which accepts an operation code, and zero to two inputs depending on the operation code. Based on the operation code, you will call three versions of the overlaoded function textProcessing as follows: Operation 0: The function removes all vowels from the ORIGINAL sentence. The vowels considered are the small letters (a, e, i, o, u y, and w). Operation 1: The code further asks for one lowercase letter to be input by the user. If the character is not a lower case letter, the code outputs Invalid. The function returns the distance (difference) between the letter first occurence and last occurence in the text. If the letter does not occur in the sentence, it returns 0. Operation 2: The code asks for two lowercase letters to be input by the user. If the characters are not lower case letters, the…arrow_forward
- Module/Week 5 ASSIGNMENT (USER-DEFINED FUNCTIONS)Write a C++ program that reads data from an input file, takes the data and computes student grades for an assignment by converting the raw score to a percentage given each student's score and the total points. The final score must be rounded up to the nearest whole value using the ceil function in the <cmath> header file and displayed as a percentage. You must also display the floating-point result up to 5 decimal places. You must use at least 2 functions: one to print the last name of the student and another function to compute and print the percentage as well as "Excellent" if the grade is greater than 90, "Well Done" if the grade is greater than 80, "Good" if the grade is greater than 70, "Need Improvement" if the grade is greater than or equal to 60, and "Fail" if the grade is less than 50. The main function is responsible for reading the input file and passing the appropriate arguments to your functions. Here is an example of…arrow_forward- In C++ using Visual Studio - Seperate the files if there is any .cpp, .main or .h files. PART 1Read the contents of the text file and store them in a C++ data structure called std::map<string, int>This map is a collection of sorted <key, value> pairsIn this case, the keys are unique words found in the text file, and the values represent the number of times each word appearsFor example, since the word "cat" appears twice in the file, then map["cat"] = 2 PART 2Iterate through the map and print each key in the order they appearThis will give you a sorted list of unique wordsHere's the expected result: "a big cat does everything feeding goats helping injured juvenile kangaroos locating missing notorious objects playing quietly reading superb tales upvoting videos with xylophone yielding zebras" PART 3Iterate through the map again, this time printing each associated valueThe values represent how many times each word was found in the text filePay attention to the sequence of…arrow_forwardC++ - No library functions like atoi Write a machine language program to input two one-digit numbers, add them, and output the one-digit sum. Submit your "machine code" followed by a 'zz.'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
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