each line of file contains 6 inpus, (3 points in 2D
plane).
1) While file is not end
2) We are reading these 6 variable in 3 aThing struct
variable.
3) Function theseAreGreenEggsAndHam checks if these
three points are collinear, that is
if slope of (A, C) is same as slope
of (A, B)
so, if (A.one - C.one) / (A.two -
C.two) == (A.one - B.one) / (A.two - B.two)) return true;
else
return false.
for the 1st input A(1, 2), B(2, 4),
C(3, 6)
(A.one - C.one)
/ (A.two - C.two) = (1 - 3) / (2 - 6) = 2 / 4 = 1 / 2
(A.one - C.one)
/ (A.two - C.two) = (1 - 2) / (2 - 4) = 1 / 2
equal so, it
returns false,
for the 2nd input A(-8, 2), B(0,
0), C(6, 3)
(A.one - C.one)
/ (A.two - C.two) = (-8 - 6) / (2 - 3) = -14 / -1 = 14 / 1
(A.one - C.one)
/ (A.two - C.two) = (-8 - 0) / (2 - 0) = -8/ 2 = -4 / 1
not equal, so it
returns false
4) Print yes if lines are collinear, along with
points
Print no if lines are not
collinear, along with points
output:
sanjiv@sanjiv-VirtualBox:~$ g++ file1.cpp -o
file1
sanjiv@sanjiv-VirtualBox:~$
sanjiv@sanjiv-VirtualBox:~$ ./file1
YES :1 2,2 4,3 6.
NO :-8 2,0 0,6 3.
Show full handtracing of the following code and describe what it accomplishes. Show full handtracing of...
1. What would be the output of the following lines of code: int num = 2; switch(num){ case 1: cout << "1"; case 2: cout << "2"; case 3: cout << "3"; case 4: cout << "4"; } 2. What would be the output of the following code: char op = '*'; switch(op){ case '+': cout << "Addition"; break; case '-': cout << "Subtraction"; break; case '/': cout << "Division"; break; default: cout << "Invalid"; } 3. What would be...
I need help debugging this C++ prgram. What Am i doing wrong? //******************************************************** // This program reads two input files whose lines are //ordered by a key data field. This program should merge //these two files, writing an output file that contains //all lines from both files ordered by the same key field. // //********************************************************* #include <iostream> #include<string> #include<fstream> //prototype void mergeTwoFiles (ifstream&,ifstream&, ofstream&); using namespace std; int main() {string inFile1,inFile2,outFile; // input and output files ifstream in1; ifstream in2;...
How do I complete my code using an external file? External file: data.txt //the number 6 is in the external file Incomplete code: #include <iostream> #include <fstream> using namespace std; class example { int data[1]; public: example(); void read(ifstream &); }; example::example() { ifstream infile; infile.open("data.txt"); } void example::read(ifstream &infile) { infile >> data[1]; cout << data[1] << endl; } int main() { example example, read; //system("pause"); return 0;...
The following code is for Chapter 13 Programming Exercise 21. I'm not sure what all is wrong with the code written. I get errors about stockSym being private and some others after that.This was written in the Dev C++ software. Can someone help me figure out what is wrong with the code with notes of what was wrong to correct it? #include <cstdlib> #include <iostream> #include <iomanip> #include <fstream> #include <cassert> #include <string> using namespace std; template <class stockType> class...
Can someone help me put the string removee the return to an outfile and fix?? prompt: CS 575 LabEx14: no e’s Let the user specify an input file and an output file (text files). Read the input file and write the output file; the output file should be the same as the input file, except that it has no e’s. For example, if the input file had the line. Streets meet in the deep. Then the output file would have...
hello there. can you please help me to complete this code. thank you. Lab #3 - Classes/Constructors Part I - Fill in the missing parts of this code #include<iostream> #include<string> #include<fstream> using namespace std; class classGrades { public: void printlist() const; void inputGrades(ifstream &); double returnAvg() const; void setName(string); void setNumStudents(int); classGrades(); classGrades(int); private: int gradeList[30]; int numStudents; string name; }; int main() { ...
//This program is your final exam. //Please fill in the functions at the bottom of the file. (evenCount and insertItem) //DO NOT CHANGE ANYTHING ELSE. //main has all the code needed to test your functions. Once your functions are written, please build and make sure it works fine //Note that in this case, the list is not sorted and does not need to be. Your goal is to insert the number in the given position. #include <iostream> #include <fstream> using...
//This program is your final exam. //Please fill in the functions at the bottom of the file. (evenCount and insertItem) //DO NOT CHANGE ANYTHING ELSE. //main has all the code needed to test your functions. Once your functions are written, please build and make sure it works fine //Note that in this case, the list is not sorted and does not need to be. Your goal is to insert the number in the given position. #include <iostream> #include <fstream> using...
//This program is your final practice exam. //Please fill in the functions at the bottom of the file. (sum and removeItem) //DO NOT CHANGE ANYTHING ELSE. //main has all the code needed to test your functions. Once your functions are written, please build and make sure it works fine //Note that in this case, the list is not sorted and does not need to be. Your goal is to insert the number in the given position. #include <iostream> #include <fstream>...
can some help me why it is erroring. I cannot find the mistake in the code. It is to implment a circular double linked list. please and thank you ////////////////////////////////////////////////////////////////////////// HEADER FILE //////////////////////////////////////////////////////////////////////// #pragma once #include <cstdlib> template <typename T> class Node { public: T val; Node<T> *next; Node(T v) { val = v; next = NULL; } }; /////////////////////////////////////////////////////////////////////////////////// STACK.CPP FILE /////////////////////////////////////////////////////////////////////////////////// #include "Stack.h" template <typename T> class Stack {...