GradePack

    • Home
    • Blog
Skip to content
bg
bg
bg
bg

GradePack

Write a class called ItemOrder that stores information about…

Write a class called ItemOrder that stores information about an item being ordered. Each ItemOrder object should keep track of its item number (a string), an integer quantity, and a price per item. The price will be passed to the constructor as an integer number of pennies. For example: ItemOrder* item1 = new ItemOrder(“007”, 3, 36); Notice that the quantity is passed as a parameter before the price in the constructor, so this indicates an order for item number 007 with a quantity of 3 at 36 cents each. The total price for this order would be 108 cents. In addition to the constructor described above, the class should include the following public member functions and operator overloads: member function description getItem() returns the item number for this item as a string getPrice() returns the total price for this order in pennies getQuantity() returns the total quantity this order is for operators description

Read Details

O(N2) Sort Write the state of the elements in the vector bel…

O(N2) Sort Write the state of the elements in the vector below after each of the first 3 passes of the outermost loop of the selection sort algorithm. vector numbers {63, 9, 45, 72, 27, 18, 54, 36}; selectionSort(numbers); after pass 1: [p1] after pass 2: [p2] after pass 3: [p3] Merge Sort Trace the complete execution of the merge sort algorithm when called on the vector below, similarly to the example of merge sort shown in the lecture slides. Show the sub-vectors that are created by the algorithm and show the merging of sub-vectors into larger sorted vectors. vector numbers {22, 88, 44, 33, 77, 66, 11, 55}; mergeSort(numbers); Make sure to format your answers with each sub-vectorsurrounded by { } braces, such as {1, 2} {3, 4}. 1st split      [s1] 2nd split     [s2] 3rd split      [s3] 1st merge   [m1] 2nd merge  [m2] 3rd merge   [m3] Binary Search Suppose we are performing a binary search on a sorted vector called numbers initialized as follows: // index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 vector numbers {-2, 0, 1, 7, 9, 16, 19, 28, 31, 40, 52, 68, 85, 99}; ​ int index = binarySearch(numbers, 5); Write the indexes of the elements that would be examined by the binary search (the mid values in our algorithm’s code) and write the value that would be returned from the search. Assume that we are using the binary search algorithm shown in class. indexes examined: [e1] values returned:     [e2]

Read Details

Write a function called filterDistance that takes a referenc…

Write a function called filterDistance that takes a reference to a vector of pointers to Point objects, an individual Point object and a real number representing a distance as parameters. Your function should move any Points in the vector that are a greater distance from individual Point than the passed in distance to the end. They can end up in any order after your function runs as long as all points greater than the passed in distance away are after all points less than or equal to the passed in distance. For example if we run the code below: vector points {new Point(1, 2), new Point(90, 200), new Point(100, 100), new Point(4, 5), new Point(1, 2), new Point(100, 200)}; Point location(10, 10); filterDistance(points, location, 30); We will find points contains points (1, 2), (4, 5), (1, 2) before points (90, 200), (100, 100), (100, 200) as the distance between the first three and location is less than or equal to 30 and the distance between location and the last three is greater than 30. Point objects have the following public members: Name Description Point(int x, int y) constructs a point with the given coordinates int getX() returns the x coordinate int getY() returns the y coordinate double distance(Point p) returns the distance between this point and the passed in point

Read Details

CS 132 Final Cheat Sheet for (initialization; test; update)…

CS 132 Final Cheat Sheet for (initialization; test; update) { statement(s); … } if (test) { statement(s); } else if (test) { statement(s); } else { statement(s); } while (condition) { statement(s); } type name(parameters) { statement(s); … return expression; } Math Description fabs(value) absolute value sqrt(value) square root round(value) Rounds to the nearest whole number pow(b, e) base to the exponent power   User Input Description getline(cin, variable) reads an entire line of input as a string and stores in variable cin >> variable reads a single token and stores in variable as whatever type variable is declared as   Random Description rand() random integer from 0 to max number srand(time(0)) Seeds random with the current time   Strings String function name Description string(1, chr) converts a character into a string s.append(str) Adds str onto the end of s s.erase(index, length) Removes length number of characters starting at index s.find(str) s.rfind(str) Returns the starting position of str in s (first occurrence for find, last for rfind). Returns string::npos otherwise. s.insert(index, str) Inserts str into s starting at index s.length()  or  s.size() Returns the number of characters in s s.replace(index, len, str) Replaces length characters starting with the character at index with str. s.substr(start, length)  or s.substr(start) Returns a substring of s. Does not alter s.   Character Function Description tolower(ch1) Returns ch1 in lowercase toupper(ch1) Returns ch1 in uppercase isalnum(ch1) Returns true if ch1 is alphanumeric isalpha(ch1) Returns true if ch1 is alphabetic isdigit(ch1) Returns true if ch1 is a decimal digit islower(ch1) Returns true if ch1 is a lowercase letter ispunct(ch1) Returns true if ch1 is a punctuation character isspace(ch1) Returns true if ch1 is white-space isupper(ch1) Returns true if ch1 is an uppercase letter   Streams Stream function Description f.clear(); resets stream’s error state, if any f.close(); stops reading file f.eof() returns true if stream is past end-of-file (EOF) f.fail() returns true if the last read call failed (e.g. EOF) f.good() returns true if the file exists f.get() reads and returns one character f.open(“filename”);f.open(s.c_str()); opens file represented by given C string (may need to write .c_str() if a C++ string is passed) f.unget(ch) un-reads one character f >> var reads data from input file into a variable (like cin);reads one whitespace-separated token at a time getline(f&, s&) reads line of input into a string by reference;returns a true/false indicator of success   Vectors vector member functions Description v.push_back(value); appends value at end of vector v.pop_back(); removes the value at the end of the vector v.clear(); removes all elements v[i] or get(i) returns a reference to the value at given index, get throws an exception if i is out of bounds, [] doesn’t v.insert(iterator, value); inserts given value at the index the iterator points to v.empty() returns true if the vector contains no elements v.erase(start, stop); removes values from start iterator position (inclusive) to stop iterator (exclusive) v[i] = value;  replaces value at given index v.size() returns the number of elements in vector v.begin() returns an iterator pointing to the beginning v.end(); returns an iterator pointing to the end v.cbegin(); returns a const iterator pointing to the beginning v.cend(); returns a const iterator pointing to the end v.rbegin(); returns an iterator pointing to the beginning that moves backwards v.rend() returns an iterator pointing to the end that moves backwards   Classes .h file template: #ifndef _classname_h #define _classname_h class ClassName { public:                          // in ClassName.h     ClassName(parameters);       // constructor     returnType name(parameters); // member functions     returnType name(parameters); // (behavior inside     returnType name(parameters); //  each object) private:     type name;     // member variables     type name;     // (data inside each object) }; #endif   .cpp File Template: #include “ClassName.h” // member function returnType ClassName::methodName(parameters) {     statements; }   Operator Overloading General Template returnType operator op(parameters);      // .h returnType operator op(parameters) {     // .cpp     statements; };   Printing: ostream& operator

Read Details

Mi semestre Fill in the blanks with the present tense of the…

Mi semestre Fill in the blanks with the present tense of the Spanish verb. (10 x 1.5 pts. each = 15 pts.) Tomás, Patricia y yo somos estudiantes; nosotros (1)  _______ (regresar / estudiar) en la universidad. Tomás y Patricia (2) _______ (necesitar / enseñar) llegar a la universidad a las nueve. Patricia (3) _______ (tomar / llevar) una clase de inglés y Tomás (4) _______ (cantar / trabajar) en la biblioteca. Mi primera (first) clase es a las once de la mañana. Entonces (so) yo (5) _______ (desayunar / bailar) y (6) _______ (buscar / mirar) televisión en la residencia estudiantil. Me (7) _______ (conversar / gustar) los programas de ciencias y de animales. Y a ti, ¿te gusta (8) _______ (dibujar / mirar) programas educativos (educational)?

Read Details

1. Explain the concept of “conjugation”. How do you conjugat…

1. Explain the concept of “conjugation”. How do you conjugate in Spanish? And in English? 2. Explain the difference between SER and ESTAR. Responses based in course materials that can be found in eLearn are ideal. 

Read Details

Listen to the five following questions and answer them in th…

Listen to the five following questions and answer them in the box below in full sentences in Spanish (5x 3pts each= 15 points) 

Read Details

Lectura Read Juan Antonio’s e-mail to his sister and answer…

Lectura Read Juan Antonio’s e-mail to his sister and answer the questions with sentences. (5 x 2 pts. each = 10 pts.)   Estoy en la biblioteca que está al lado de la residencia estudiantil. Me gusta la biblioteca porque sólo1 hay once estudiantes ahora. Cuando deseo descansar, camino a la cafetería porque está muy cerca de la biblioteca y tomo un café2. Estudio aquí porque Dan, mi compañero de cuarto, está en la residencia con unos chicos y yo necesito preparar el examen de historia. El examen es el viernes a las 10 de la mañana. También necesito preparar la tarea de biología. Necesito estudiar mucho. 1only   2 coffee    1. ¿Dónde está la biblioteca? 2. ¿Por qué le gusta la biblioteca a Juan Antonio? 3. ¿Quién toma un café cuando necesita descansar? 4. ¿Quién es Dan? 5. ¿A qué hora es el examen de Juan Antonio?

Read Details

Tú Write a paragraph in Spanish with at least five sentences…

Tú Write a paragraph in Spanish with at least five sentences in which you mention the courses your best friend is taking this semester, when they are (day and time), whether he/she likes the classes, whether he/she works, and the things he/she likes to do when they are not studying. Keep it simple and use exclusively vocabulary and grammar from lessons 1 and 2. (6 pts. for vocabulary + 6 pts. for grammar + 3 pts. for style and creativity= 15 pts.)

Read Details

​Clients who are court-ordered to see a practitioner have no…

​Clients who are court-ordered to see a practitioner have no choice in the matter.

Read Details

Posts pagination

Newer posts 1 … 43,916 43,917 43,918 43,919 43,920 … 56,725 Older posts

GradePack

  • Privacy Policy
  • Terms of Service
Top