[SOLVED] CSE102 Assignment 4-Graph of a given quadratic equation

30.00 $

Category: Tags: , , , , , ,
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon assignment-4-0o64ry.zip (428.2 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
Rate this product

In this assignment, you are asked to write a program that draws the graph of a given quadratic equation. The program should consist of 3 parts as described below.

Part 0: The program should have an infinite loop that asks the user to select the operation and this loop should stop running only when the user chooses to exit. It should also warn the user if an improper input is given.

Expected output

Part 1 (10pts): The program gets the coefficients of the equation as input. Since there are three coefficient in a quadratic equation, user should enter three integers. These 3 integers should be written line by line to a .txt file called “coefficients.txt” which has been created during this part of the program. P.S. Since the program will print the graph line by line, the variable in the equation should be y coordinates instead of x as following: 𝑥 = 𝑎 ⋅ 𝑦2 + 𝑏 ⋅ 𝑦 + 𝑐

Expected outputs Terminal:

Page 1 of 5

CSE102 – Spring 2022 Homework #4

Txt file:

Part 2 (80 pts): In this part, the program should draw the graph of the equation on the 2D cartesian plane. First, it should read the “coefficients.txt” file and get the coefficients (if the file is not present, it should warn the user), and then draw the graph of it.

Drawing the graph:

  • –  The program should draw a graph in a range of [-55, 55] for x values and [15,-15] for y values (to see the graph properly in the terminal).-
  • –  The graph should be written line by line. For instance, it should print P1(-55,15) first. And thenP2(-54,15) next to it. Once it prints P3(55,15) it should go to the next line and start again with the point (-55,14). To understand it better, check the following picture (the picture is not correlated with the expected output of the program).

– When printing a point on the cartesian plane:
o If the point is not on the graph of the equation, and it is not on the x or y-axis, a space

should be printed for that point.
o If the point is on the graph of the equation, it should be printed as #.
o If the point is on the x-axis or y-axis, the program should use “-” and “|” characters to

draw a horizontal or a vertical line.

  • –  On the x-axis, print a number for every 10 units to empathize the coordinates of the graph. Thenumbers should be under the x-axis. Make sure these numbers don’t overwrite the points of

    the graph of the equation (i.e. # characters).

  • –  The program should repeat the last step for the y-axis as well. But the numbers should beprinted every 5 units and they should be at the left side of the y-axis.
  • –  Use different colors to draw a more understandable graph. Check this page to see the codeblock (which consists of only 3 lines).

Page 2 of 5

CSE102 – Spring 2022

Homework #4

Expected outputs: The graph of 𝑥 = 𝑦2

The graph of 𝑥 = 𝑦 + 5

The graph of 𝑥 = − 10

Page 3 of 5

CSE102 – Spring 2022 Homework #4

Part 3 (10 pts): The program should print the same graph to the “graph.txt” file. In this part, the program should follow the same steps as in Part2 (without colors and printing numbers).

Expected outputs: The graph of 𝑥 = 𝑦2

The graph of 𝑥 = − 10

Page 4 of 5

CSE102 – Spring 2022

Homework #4

General Rules:

  1. Only stdio.h library is allowed.
  2. You can write your own functions for clear coding.
  3. Assume that the inputs (coefficients) will be given properly (as integers).
  4. Using arrays is not allowed.
  5. Make sure that your program can print a graph properly within the given ranges.
  6. Hint: While printing the numbers to emphasize the coordinates of an axis, you may need todelete a few characters which you already printed. You can use “\b” to delete a character you

    just printed, it works for both console and file.

  7. If you have any questions about this homework, please ask them through the assignment poston the Teams, so that everyone can see the answer.

Page 5 of 5

  • assignment-4-0o64ry.zip