Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Textbook Question
Chapter 18.1, Problem 1STE
If v is a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
In Python please help with the following:
a) Write a class in Python called Vector2d whose initializer receives two numbers: x,y.Define an instance method called translateby that receives two numbers: dx and dy and translates the vector by dx and dy. Translating vector v by dx and dy makes the vector's x and y incremented by dx and dy, respectively.For example: (1, 2) translated by 3, and 4 results in (4,6).Define a static method called sum that receives two vectors and returns a newvector whose value equals the sum of the two vectors.
B) Test your code by implementing the following:• Create a vector v1, instantiate it with (1, 2).• Create a vector v2, instantiate it with (2, 4).• Calculate the sum of the two vectors in v3.• Translate v3 by 1 and 2.• Print v3's coordinates. It prints 4, 8.
Could you correct the error
in C++ mathematical functions language
Chapter 18 Solutions
Problem Solving with C++ (9th Edition)
Ch. 18.1 - If v is a vector, what does v.begin() return? What...Ch. 18.1 - If p is an iterator for a vector object v, what is...Ch. 18.1 - Suppose v is a vector of ints. Write a for loop...Ch. 18.1 - Suppose the vector v contains the letters 'A',...Ch. 18.1 - Suppose the vector v contains the letters 'A',...Ch. 18.1 - Suppose you want to run the following code, where...Ch. 18.2 - Prob. 7STECh. 18.2 - Prob. 8STECh. 18.2 - Prob. 9STECh. 18.2 - Prob. 10STE
Ch. 18.2 - Prob. 11STECh. 18.2 - Prob. 12STECh. 18.2 - Prob. 13STECh. 18.2 - Prob. 14STECh. 18.2 - Prob. 15STECh. 18.2 - Prob. 16STECh. 18.3 - Prob. 17STECh. 18.3 - Prob. 18STECh. 18.3 - Prob. 19STECh. 18.3 - Suppose v is an object of the class vectorint. Use...Ch. 18.3 - Prob. 21STECh. 18.3 - Can you use the copy template function with vector...Ch. 18.3 - Prob. 23STECh. 18 - Prob. 1PCh. 18 - Prob. 2PCh. 18 - Prob. 3PCh. 18 - Prob. 4PCh. 18 - Write a program that allows the user to enter any...Ch. 18 - Prob. 3PPCh. 18 - Prob. 5PPCh. 18 - Solution to Programming Project 18.6 In this...Ch. 18 - Prob. 7PPCh. 18 - You have collected a file of movie ratings where...Ch. 18 - Prob. 9PP
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Combine the statements that you wrote in Exercise 4.5 into a Java application that calculates and prints the su...
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
The following perfectly valid C program was written without much attention paid to its format. As you will obse...
Programming in C
What is the purpose of the let constructs in functional languages?
Concepts of Programming Languages (11th Edition)
(This is a variant of an exercise from Chapter 1.) Create a text file that contains the text " I hate programmi...
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)
(Decimal to hex) Write a recursive method that converts a decimal number into a hex number as a string. The met...
Introduction to Java Programming and Data Structures, Comprehensive Version (11th 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
- in C++ 3D Vector languagearrow_forwardDon't use vector array .using ifstream and ofstream. C++ programarrow_forwardIn c++ Please Write the InOrder() function, which receives a vector of integers as a parameter, and returns true if the numbers are sorted (in order from low to high) or false otherwise. The program outputs "In order" if the vector is sorted, or "Not in order" if the vector is not sorted. Ex: If the vector passed to the InOrder() function is [5, 6, 7, 8, 3], then the function returns false and the program outputs: Not in order Ex: If the vector passed to the InOrder() function is [5, 6, #include <iostream>#include <vector>using namespace std; bool InOrder(vector<int> nums) { /* Type your code here */} int main() { vector<int> nums1(5); nums1.at(0) = 5; nums1.at(1) = 6; nums1.at(2) = 7; nums1.at(3) = 8; nums1.at(4) = 3; if (InOrder(nums1)) { cout << "In order" << endl; } else { cout << "Not in order" << endl; } vector<int> nums2(5); nums2.at(0) = 5; nums2.at(1) = 6;…arrow_forward
- in c++ Write a function named “getLowest” that accepts a vector of pointers to Student objects. It will go through the list and return pointers to the Student or GradStudent with the lowest student ID and GPA. Please note that the vector contains pointers to either Student or GradStudent objects. Please show that you have tested with a vector of pointers of mixed Student and GradStudent objects (in the same vector) For example, if these students and grad students are in the list Student(2000, "John Smith", 4.0) GradStudent(3000,"Nancy Brown", 3.5, 2021) ; Student(1000, "Bob Johnson", 3.0) ; GradStudent(4000, "Tim Jackson", 2.0, 2020)) ; It will return pointers to these two objects: Lowest ID: ID(1000) NAME(Bob Johnson) GPA(3.00) Lowest GPA: ID(4000) NAME(Tim Jackson) GPA(2.00) GRADUATION-YEAR(2020)arrow_forwardCreate an vector of foods in C++ and then ask user for its favourite food. If favourite food is present then print "your food will be served soon" otherwise print "Sorry".arrow_forwardmergeAndRemove(int[], int[]) This is a public static function that takes a int[] and int[] for the parameters and returns an int[]. Given two arrays of integers. Your job is to combine them into a single array and remove any duplicates, finally return the merged array.arrow_forward
- C++ don't use previous answers they have missing info Please expand my code and call the destructor that prints something a bunch of times and follow guidelines. TYSM A. Extend the driver class to do the following: Declare a vector of circles Call a function with signature inputData(vector<Circle> &, string filename) that reads data from a file called dataLab4.txt into the vector. The following 3-5 are done in this function Use istringstream to create an input string stream called instream. Initialize it with each string that is read from the data file using the getline method. Read the coordinates for the center and the radius from instream to create the circles Include a try catch statement to take care of the exception that would occur if there was a file open error. Display the message "File Open Error" and exit if the exception occurs Display all the circles in this vector using the toString method Use an iterator to iterate through the vector to display these circles…arrow_forwardYou may use the vector and iostream libraries. You are allowed to use three built-in vector member functions (and no others) but you may not have to use them all. The member functions you are allowed to use are size(), at(), and push_back() Write a function that outputs a vector of doubles with each number in the vector separated by a space then a newline after the entire vector is output. The whole vector output should be preceded by a single line saying "Current Vector Contents:". Write a function that takes a vector a doubles and reverses the order of all the elements of the vector. Write a function that fills a vector of doubles with positive numbers using the standard input stream cin, terminate the input when the user enters any negative number. A single output prompt should precede the initial input stating directions for user. Write a main function that creates an empty vector, calls functions from 2 & 3 and calls your output function before and after each of your calls…arrow_forwardWrite a program that will sort a prmiitive array of data using the following guidelines - DO NOT USE VECTORS, COLLECTIONS, SETS or any other data structures from your programming language. This will also use your 'Currency' and 'Money' classes from the previous lab, so everything for this lab will be in a new file for 'main'. (Programming language Java) Create a helper function called 'RecurInsSort' such that: It is a standalone function not part of any class from the prior lab or any new class you feel like creating here, Takes in the same type of parameters as any standard Insertion Sort with recursion behavior, i.e. void RecurInsSort(Currency arr[], int size) Prints out how the array looks every time a recursive step returns back to its caller The objects in the array should be Money objects added or manipulated using Currency references/pointers. It is OK to print out the array partially when returning from a particular step as long as the process of sorting is clearly…arrow_forward
- Java Program - Functions with 2D Arrays Write a function named displayElements that takes a two-dimensional array, the size of its rows and columns, then prints every element of a two-dimensional array. Separate every row by a new line and every column by a space. In the main function, write a program that asks for integer input to be assigned on a 3 x 3 array and call the function displayElements to print the contents on the next line. Input 1. Multiple lines containing integer each line Output R1C1: 1 R1C2: 2 R1C3: 3 R2C1: 4 R2C2: 5 R2C3: 6 R3C1: 7 R3C2: 8 R3C3: 9 1 2 3 4 5 6 7 8 9arrow_forwardIN C++ Given a vector of vectors of strings called items that contain items {{"Target", "LA", "Eggs,40,$0.78", "Candy,4,$0.51"}, {"Walmart", "MI", "Eggs,2,$0.50"},{"Kroger", "WI", "Soda,5,$1.56"}}, and another vector with the items you wanna shop, shopitems{"10 Eggs", "1 Candy"}. Say you want the items in shop items, how you iterate and grab the lowest-cost items, its name of store, its location, its amount of eggs, and its cost. You have to take into consideration that some shops only have a certain amount of items, for example, if you need 10 eggs, you're going to have to get 2 at Walmart and the other 8 at Target. In the end, total the price of the items needed.arrow_forwardhi please me on this to fix the error and this is not the graded question so please dont cancel the question. this is a homework question and i need helparrow_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
9.1: What is an Array? - Processing Tutorial; Author: The Coding Train;https://www.youtube.com/watch?v=NptnmWvkbTw;License: Standard Youtube License