Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a console application that repeatedly reads data from the keyboard compute

ID: 3620767 • Letter: W

Question

Write a console application that repeatedly reads data from the keyboard
computes with it and produces a table of output. For each set of data you will read four
numbers representing two points in 2D Cartesian space. The first two items of data
represent the (x,y) coordinates of one point and the second two items of data represent the
(x,y) coordinates of a second point. After reading the four integers, write them out using
traditional coordinate point notation, followed by the distance between them and the
volume of a sphere whose radius is equal to the distance between the points. Continue
reading and processing data until the user enters four zeros. At that point skip one blank
line and display the message “End of Output”. The formula for computing the distance
between two points (x1,y1) and (x2,y2) is distance formulav(x2-x1)squre +(y2-y1)squre
The formula for
computing the volume of a sphere is 4/3ppr3.
In addition to the basic processing requirement described, your program must In addition to the basic processing requirement described, your program must
perform the following:
1. Display instructions for using the program when it is started, i.e., what the
program does, what kind and how much data to enter each time, and
finally how to stop the program.
2. Prompt the user to enter each of the four items of data each time data is
needed. The numbers should be integers and contain no more than four
digits each. You will read each of the four numbers one at a time from the
same line of input.
3. Compute the distance between two points and the volume of the sphere
whose radius is equal to the distance between the two points.
4. Display the output as a table. Display appropriate column headers.
Display the two points and the distance between them on a single line.
Display the volume of the sphere on the next line aligned under the
distance. Use composite format codes to separate the items displayed so they are more readable and properly aligned. The distance and volume data must be displayed with exactly 3-digits after the decimal point.
5. The output table should look like, this example:
Point < Point & Calculations
(1,1) (2,2) Distance = 1.414
Volume = 11.848
(8,-10) (30,-5) Distance = 22.561
Volume = 48102.238
Notice the alignment and spacing of the items within the table.
6. You may use formatted output, i.e., you can use composite formatting (i.e., curly-brace) notation within your program output strings. You may use the ToString-methods with a display code parameter. You may also perform some output without using formatted output. You can use string concatenation for some or all of your output.
7. After displaying the last line of data, skip exactly one blank line before and after displaying the left justified message End of Output. Adding this message to the end of program output helps visual debugging. If the message does not appear, some of the last items of data may also not appear. if you need more information just email me my email add hetom_1983@yahoo.com

Explanation / Answer

Hi, Someone else asked this recently so I'll just copy my response below... static void Main(string[] args) { // new position class Position pos = new Position(); // results double distance = 0.0; double volume = 0.0; // result strings string str_distance = null; string str_volume = null; // print start message Console.WriteLine("**********************************"); Console.WriteLine("* Distance and Volume Calculator *"); Console.WriteLine("********************************** "); Console.WriteLine("This program takes in 4 integer values from the user for coordinates."); Console.WriteLine("These values are input as follows, x1, y1, x2, and y2. From these integers"); Console.WriteLine("(treated as coordinate points) the distance between the two is calculated."); Console.WriteLine("Also, treating the distance as a radius, the volume of a sphere is calculated"); Console.WriteLine("and displayed with the coordinate points and distance results. "); Console.WriteLine("Enter integer values for coordinate points as long as you wish the program to run."); Console.WriteLine("When you want to quit, simply enter 4 0's for x1, y1, x2, and y2 respectively."); Console.WriteLine("The program will then terminate... "); // infinite loop (breaks when condition is met below => all numbers are 0) while (true) { // Get x1 from user Console.Write("Enter x1: "); pos.x1 = Convert.ToInt32(Console.ReadLine()); // Get y1 from user Console.Write("Enter y1: "); pos.y1 = Convert.ToInt32(Console.ReadLine()); // Get x2 from user Console.Write("Enter x2: "); pos.x2 = Convert.ToInt32(Console.ReadLine()); // Get y2 from user Console.Write("Enter y1: "); pos.y2 = Convert.ToInt32(Console.ReadLine()); // if all zeros, then return (exit) if (pos.Zeros()) { Console.WriteLine(); return; } // calculate distance distance = pos.GetDistance(); // calculate volume volume = pos.GetVolume(distance); // convert doubles to correctly formatted strings str_distance = String.Format("{0:0.000}", distance); str_volume = String.Format("{0:0.000}", volume); // print results in table form using arguments and formatting Console.WriteLine(" Point #1 Point#2 Calculations"); Console.WriteLine("({0},{1}) ({2},{3}) Distance = {4}", pos.x1, pos.y1, pos.x2, pos.y2, str_distance); Console.WriteLine(" Volume = {0} ", str_volume); } } } // Class used to hold values and perform calculations class Position { // coordinate values/integers public int x1; public int x2; public int y1; public int y2; // Constructor public Position() { this.x1 = 0; this.x2 = 0; this.y1 = 0; this.y2 = 0; } // Calculates distance, returns as a double public double GetDistance() { double x = 0.0; double y = 0.0; // (x2 - x1)^2 x = Math.Pow((this.x2 - this.x1), 2.0); // (y2 - y1)^2 y = Math.Pow((this.y2 - this.y1), 2.0); // sqrt( (x2 - x1)^2 + (y2 - y1)^2 ) return (Math.Sqrt(x + y)); } public bool Zeros() { // if all zeros, then return true return (((this.x1 == 0) && (this.x2 == 0) && (this.y1 == 0) && (this.y2 == 0))); } public double GetVolume(double radius) { // (4/3) * pi * r^3 return ((4.0 / 3.0) * Math.PI * Math.Pow(radius, 3.0)); } };

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote