Problem Solving with C++, Student Value Edition
10th Edition
ISBN: 9780134543680
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8.1, Problem 3STE
What (if anything) is wrong with the following code?
char stringVar[] = “Hello”;
strcat(stringVar, “ and Good–bye.”);
cout << stringVar;
Assume that the code is embedded in a complete
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
can you please remove error from deposit and withdraw section.
#include<iostream>#include<fstream>#include<string>using namespace std;
string user;string pass;
void Register();int LoginCheck (string user, string pass);
class Bank{protected:int accountNumber;string fname;string lname;string CNIC;long balance;public:void openAccount(int accountNumber, string fname,string lname,string CNIC,long balance);void checkBalance(int find);void depositeAmount(int f);void withdrawAmount(int f);void removeAccount(int find);virtual void stdisplayall() = 0;};class data{public:int accountNumber;string fname;string lname;string CNIC;long balance;};class Account: public Bank{ data obj[10];public:void openAccount(int accountNumber, string fname,string lname,string CNIC,long balance){fstream myFile;myFile.open("temp.txt",ios::app);if (!myFile.is_open()){cout << "file not found" << endl;}else{this->accountNumber = accountNumber;this->fname = fname;this->lname =…
There is a code below this template. The template must be implemented into the code but I am unable to run the code whenever I try to implement the code. How do I inmplement the template into the code?
// -- brief statement as to the file’s purpose
//XXXX-XXX- ADD YOUR SECTION NUMBER
// //Include statements
#include <iostream>
#include <string>
using namespace std;
//Global declarations: Constants and type definitions only -- no variables
//Function prototypes
int main()
{
//In cout statement below SUBSTITUTE your name and lab number
cout << "Your name -- Lab Number" << endl << endl;
//Variable declarations
//Program logic
//Closing program statements
system("pause");
return 0;
}
//Function definitions
Code:
#include <iostream> // Defining a header file
#include <string> // Defining a header file
using namespace std;
//Enum planetType
enum planetType {
Mercury, Venus,
Earth, Moon,
Mars, Jupiter,
Saturn, Uranus,
Neptune, Pluto };
//…
1) The input function returns a numeric value by default.
a. True
b. False
2) Strings are mutable objects, which means you can replace their contents.
a. True
b. False
3) What is the value of string1 after the following statement is executed?
string1 = "python"[:] + "help"[:0]
a. python
b. pythonh
c. help
d. error
4) What is the last line of the output when the following code is executed?
x=2
for exp in range (0):
print ("%2d.0" % x**exp)
a. 16
b. 16.0
c. nothing
d. error
5) What is the value of newList after the following code is executed?
newList = [1, 2, 3, 4]
newList.pop()
newList.append(5)
newList.pop(2)
a. [1,3,5]
b. [3,4,5]
c. [1, 2, 5]
d. error
Chapter 8 Solutions
Problem Solving with C++, Student Value Edition
Ch. 8.1 - Prob. 1STECh. 8.1 - What C string will be stored in singingString...Ch. 8.1 - What (if anything) is wrong with the following...Ch. 8.1 - Suppose the function strlen (which returns the...Ch. 8.1 - Prob. 5STECh. 8.1 - How many characters are in each of the following...Ch. 8.1 - Prob. 7STECh. 8.1 - Given the following declaration and initialization...Ch. 8.1 - Given the declaration of a C-string variable,...Ch. 8.1 - Write code using a library function to copy the...
Ch. 8.1 - What string will be output when this code is run?...Ch. 8.1 - Prob. 12STECh. 8.1 - Consider the following code (and assume it is...Ch. 8.1 - Consider the following code (and assume it is...Ch. 8.2 - Consider the following code (and assume that it is...Ch. 8.2 - Prob. 16STECh. 8.2 - Consider the following code: string s1, s2...Ch. 8.2 - What is the output produced by the following code?...Ch. 8.3 - Is the following program legal? If so, what is the...Ch. 8.3 - What is the difference between the size and the...Ch. 8 - Create a C-string variable that contains a name,...Ch. 8 - Prob. 2PCh. 8 - Write a program that inputs a first and last name,...Ch. 8 - Write a function named firstLast2 that takes as...Ch. 8 - Write a function named swapFrontBack that takes as...Ch. 8 - Prob. 6PCh. 8 - Write a program that inputs two string variables,...Ch. 8 - Solution to Programming Project 8.1 Write a...Ch. 8 - Write a program that will read in a line of text...Ch. 8 - Give the function definition for the function with...Ch. 8 - Write a program that reads a persons name in the...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that reads in a line of text and...Ch. 8 - Write a program that can be used to train the user...Ch. 8 - Write a sorting function that is similar to...Ch. 8 - Redo Programming Project 6 from Chapter 7, but...Ch. 8 - Redo Programming Project 5 from Chapter 7, but...Ch. 8 - Prob. 11PPCh. 8 - Write a program that inputs a time from the...Ch. 8 - Solution to Programming Project 8.14 Given the...Ch. 8 - Write a function that determines if two strings...Ch. 8 - Write a program that inputs two strings (either...Ch. 8 - Write a program that manages a list of up to 10...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Fill in the blanks in each of the following: Each class declaration that begins with keyword must be stored in ...
Java How To Program (Early Objects)
For each of the following activities, give a PEAS description of the task environment and characterize it in te...
Artificial Intelligence: A Modern Approach
Define each of the following terms: entity type entity-relationship model entity instance Attribute relationshi...
Modern Database Management
Write code that will fill the following array a with numbers typed at the keyboard: int [][] a = new int [4][5]...
Java: An Introduction to Problem Solving and Programming (8th Edition)
What is the type or types of the variable(s) that can reference the object created in the following statement? ...
Java: An Introduction to Problem Solving and Programming (7th Edition)
How would the following strings be converted by the CDec function? a. 48.5000 b. 34.95 c. 2,300 d. Twelve
Starting Out With Visual Basic (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
- Please use C++ and only use libraries <iostream> and <cmath>. Also ultilize cin.ignore to let responses be recognized with a Y or Yes. Thank you!arrow_forwardWrite a function named “CheckAgainstPasswordRules” that accepts a password(string) and return true if that passwordmeets all thefollowing rules: •Length is equal or greater than 8 •Have at least one uppercase character •Have at least one lowercase character •Have at least one special character: ‘!’, ‘@’, or ‘#’ •Contain no spaces(blanks) Can you use C++ to wite this? Thanks!arrow_forwardModify task1.c so it will read from standard input, convert lowercase letters to uppercase letters, and write the output to standard output. Modify this file to convert all lowercase to uppercases letters.Hint: look at the integer value of letters in the ascii tablehttps://www.asciichart.com/Then you can use basic math.You are not allowed to use toupper() function.*/ #include <stdio.h>#include <unistd.h>#include <string.h> int main(int argc, char *argv[]){ char c; while(1){ int r = read(0,&c,1); if(r==0) break; write(1,&c, 1); } return 0;}arrow_forward
- I'm getting an error message where the FindText() is returning 0 instead of the proper amount of parameters. Here is the code #include <iostream> #include <string> using namespace std; char print_menu(string); int GetNumOfNonWSCharacters(string); int GetNumOfWords(string); void ReplaceExclamation(string&); void ShortenSpace(string&); int FindText(string, string); int main() { char opt; string tx, ph; cout << "Enter a sample text:\n\n"; getline(cin, tx); cout << "You entered: " << tx; do { opt = print_menu(tx); } while (opt == 'Q' || 'q'); // system("pause"); return 0; } char print_menu(string tx) { char ch1; string ph; cout << "\n\nMENU\n"; cout << "c - Number of non-whitespace characters\nw - Number of words\nf - Find text\nr - Replace all !'s\ns - Shorten spaces\nq - Quit"; cout << "\n\nChoose an option:\n"; cin >> ch1; switch (ch1) { case 'q': case 'Q': exit(0); case 'c': case 'C': cout << "\nNumber of…arrow_forwardI'm not sure why this program won't run , I don't have a solution explored in my c++ due to the fact I have the 2022 version on windows and I'm not sure how to make the solution explore option to show up. #include <iostream>#include <string>#include <fstream> #include <cstdlib>using namespace std; struct ch {char ck[5];int cnum;string cname;double grade; };int numlines() {cout << "opening file..." << endl;ifstream kin;kin.open("Anytest.csv");int i = 0;string temp;while (!kin.eof());{getline(kin, temp, '\n');i++;cout << "0";}kin.close();cout << " File open and input inputted." << endl;return i - 1; //file sent without title name } void Read(ch student[], int size) { //read function with a void function cout << "reading the file" << endl;ifstream kin;kin.open("afilenamedany.csv");string key, num, name, g, temp; //using temp to disregard the title name for (int i = 0; i < size; i++) {getline(kin, temp,…arrow_forwarddo some changes in code and make it unique #include <stdio.h>#include <stdlib.h>#include<string.h>//declaring functionsvoid firstFit(int [], int , int [],int );void bestFit(int [], int , int [],int );void worstFit(int [], int , int [],int );//starting programint main() {//declare partitions and processint partitions [] = {110, 450, 100, 250, 500};int processes [] = {212, 417, 112, 426};//getting their sizesint size_partitions = sizeof(partitions )/sizeof(partitions [0]);int size_processes = sizeof(processes )/sizeof(processes [0]);printf("Partitions size: ") ;for (int i=0; i<size_partitions; i++){printf("%d\t" ,partitions[i] );}//index partprintf("\nPartitions index: " );for (int i=0; i<size_partitions; i++){printf("%d\t" ,(i+1)) ;}printf( "\n" );// calling functionsfirstFit(partitions , size_partitions, processes , size_processes);bestFit(partitions , size_partitions, processes , size_processes);worstFit(partitions , size_partitions, processes ,…arrow_forward
- please provide me flow chart for the foolowing code please do not copy and paste from another place as answer will dislike #include<iostream>#include<fstream>#include<string.h>#include<iomanip> using namespace std; struct marks { string id; double quiz[2], ass[2], labTest[2]; double test, proj, final, total; char grade;}; struct marks s_marks[50]; void studentGrade(int i) { s_marks[i].total = ((s_marks[i].quiz[0] + s_marks[i].quiz[1]) * 0.05) + ((s_marks[i].ass[0] + s_marks[i].ass[1]) * 0.15) + ((s_marks[i].labTest[0] + s_marks[i].labTest[1]) * .20) + (s_marks[i].test * 0.15) + (s_marks[i].proj * 0.15) + (s_marks[i].final * 0.30); if (s_marks[i].total >= 90 && s_marks[i].total <= 100) s_marks[i].grade = 'A'; else if (s_marks[i].total >= 80 && s_marks[i].total <= 90) s_marks[i].grade = 'B'; else if (s_marks[i].total >= 60 && s_marks[i].total <= 80) s_marks[i].grade = 'C'; else if…arrow_forwardthis is my code and the question need to be continued. #include <iostream>using namespace std; class Course{private: string name; string *studentList; int size, capacity=10;public: Course(){ name = "TBD"; size = 0; studentList = new string[capacity]; }Course(string s){ name = s; size = 0; studentList = new string[capacity]; }void setName(string s){ name = s; }getter/accessor for variable name string getName(){ return name; }}; int main(){ Course a, b("Yankee"); cout << a.getName() << endl; a.setName("Mets"); cout << a.getName() << endl; cout << b.getName() << endl; return 0;} this is the Question:: Continue with Team class: a) Copy the previous program to a new file.b) Implement the addMember, removeMember and…arrow_forwardWhat will the following program display? #include <iostream> #include <string> #include <memory> using namespace std; class Base { public: Base() { cout << "Entering the base.\n"; } Base(string str) { cout << "This base is " << str << ".\n"; } virtual ~Base() { cout << "Leaving the base.\n"; } }; class Camp : public Base { public: Camp() { cout << "Entering the camp.\n"; } Camp(string str1, string str2) : Base(str1) { cout << "The camp is " << str2 << ".\n"; } }; int main() { shared_ptr<Camp> outpost = make_shared<Camp>("secure", "secluded"); return 0; }arrow_forward
- Create the .cpp file of this .h file in C++ #include <string>using namespace std;int GetNextID();class Passenger {public: Passenger(); // New passenger, assigning ID using GetNextIDPassenger(int, string, string); // ID, origin, destinationvoid Initialize(int, string, string); // ID, origin, destinationint GetID() {return ID;}string GetOrigin(){ return origin;}string GetDest() {return destination;}private:int ID; // A unique ID number for the passengerstring origin; //Airport identifierstring destination; // Airport identifierint GetNextID(); // Assigns ID's sequentially, starting with 1001};arrow_forward1. Copy the previous program to a new file. #include <iostream> using namespace std; class Vehicle{ private: string brand; public: Vehicle() { this->brand = "TBD"; } Vehicle(string brand) { this->brand = brand; } void output() { cout << "Brand: " << this->brand << endl; } string getBrand() const { return brand; } void setBrand(const string &brand_) { brand = brand_; }}; class Car:public Vehicle{ private: int *weight; //declaring dynamic variable public: Car():Vehicle() //calling Vehicle default constructor { weight=new int; //allocate memory *weight=0; //initialize weight to 0 } Car(string b, int w):Vehicle(b) //invokes Vehicle parameterized constructor {…arrow_forwardHow do you implement the following template into the code shown below it?// -- brief statement as to the file’s purpose //XXXX-XXX- ADD YOUR SECTION NUMBER //Include statements #include <iostream> #include <string> using namespace std; //Global declarations: Constants and type definitions only -- no variables //Function prototypes int main() { //In cout statement below SUBSTITUTE your name and lab number cout << "Your name -- Lab Number" << endl << endl; //Variable declarations //Program logic //Closing program statements system("pause"); return 0; } //Function definitionsCode: #include<iostream> #include<fstream> #include<string.h> using namespace std; // function prototypes void Fire(char board[][25]); void FleetSunk(char board[][25], int&); int main() { // declaring board char board[25][25]; ifstream infile; // opening the input file infile.open("game.txt");// input file location should change depending on where it is if…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