In the previous exercise you wrote a C++ program to compute the slope of a line.
ID: 3743779 • Letter: I
Question
In the previous exercise you wrote a C++ program to compute the slope of a line. For example, given the points (-1, -3) and (4, 10) input as follows -3 10 Your program computed the slope and output the points and the slope Slope: 2.6 Recall that the slope is defined as rise/run or (V2y1l)/(2-x1). In the previous exercise you were allowed to assume that the run would never be 0, thus avoiding division by 0. This assumption is no longer true. Since division by 0 is mathematically undefined, your task in this assignment is to check for run " 0.0 and n this case, avoid computing the slope and instead output "Slope: undefined" (without the . Example: given the inputs Your program should now output Slope: undefined In other words, your program should work as before except when the run as 0.0. And note the use of a to determine equality, not a single which means assignment Use an if-then-else statement to check the run and determine the appropriate course of action For additional background on if-then-else statements, read aheed into Chapter 3 (section 3.1 should be sufficient). PROGRAMMING INSTRUCTIONS A C++ template is provided to help you get started. Zyante contains a complete Cr+ programming environment, so you are free to work here. Zyante provides 2 modes: Develop' and 'Submit'. In Develop mode, you supply the input values in the text field provided, then click Run program to run your program and see the output. This gives you a chance to develop and test your program as you see fit When you are ready to submit your program for grading, switch to Submit mode, and click Submit for grading. This will un your program against the provided test cases (some of which may be hidden). The zyante system will submit a copy of your program, along with your soore In this assignment you may submit as many times as you want without penalty-zyante records your highest score if you fail to pass a test, keep in mind that auto-grading systems demand 100% precision For example, your answer wil be marked as incorrect if you do not output the requested values in the desired format-extra spaces or missing newlines will be marked as incorrect. Compare your output to the expected output to determine whats wrong Does zyante save your work? Zyante saves the most recent copy that you submitted-Le the last time you clicked the 'Run program or 'Submit for grading button If you close the browser and reload the web page, this is the version of the prograrm you will see. There is no way to go back to earlier versions, or 'save' your current work unless you Run /Submit. For this reason it is recommended that you save your work in an editor or word processcr You are free to work outside of zyante in a programming environment of your choice, but you must submit for grading using the zyante system copy paste your program nto zyante, switch to Submit mode, andSubmit for grading. Note that different programming environments have different defaults, so it's quite possible that a program working outside of zyante will fail when run inside zyante This is not an error in the zyante system- this means there is a logic error in your program. The most common mistake is failure to initialize a variable. If your program fails to produce output here in zyante, then switch to Develop mode, supply some test inputs, and Run program. Make sure your program compiles, and runs to completion. Add output statements if you need to debug furtherExplanation / Answer
#include using namespace std; int main() { int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.