import java.util.*;

public class CoordinateMath {

``````//Write your methods here
//
//
//
``````

public static void main(String[] args) {

``````   //Initialize the variables that will be filled in by the user
double x1 = 0;
double y1 = 0;
double x2 = 0;
double y2 = 0;

int userChoice = -1;

//Gather User Input
System.out.println("This program can calculate a lot of information based upon two points (x1,y1) & (x2,y2)");

Scanner in = new Scanner(System.in);

System.out.println("What is the location of x1? ");
x1= in.nextDouble();

System.out.println("What is the location of y1? ");
y1= in.nextDouble();

System.out.println("What is the location of x2? ");
x2= in.nextDouble();

System.out.println("What is the location of y2? ");
y2= in.nextDouble();

System.out.println(" ");

//Start calling Methods based upon user input

while(userChoice != 0){

System.out.println("\nWhat would you like to calculate given these two points?");
System.out.println("Enter 1 to have your two points re-printed.");
System.out.println("Enter 2 to locate the midpoint between the two given points.");
System.out.println("Enter 3 to calculate the distance between your two points.");
System.out.println("Enter 4 to calculate the slope of the line connecting the two points.");
System.out.println("Enter 5 to calculate the Y intercept of the line connecting the two points.");
System.out.println("Enter 6 to calculate the equation of your line in Slope Intercept form.");
System.out.println("Enter 7 to find the quadrant for point 1.");
System.out.println("Enter 8 to find the quadrant for point 2.");
System.out.println("Enter 9 to quit");
userChoice = in.nextInt();

// If 1 call a method that re-displays the location of the points based upon the user input

// If 2 call a method that displays the midpoint

// If 3 call a method that that displays distance between the two points

// If 4 call a method that displays the slope of the line that connects the two points

// If 5 call a method that displays the Y Intercept the line

// If 6 call a method that displays the equation of the line in slope intercept form y=mx+b

// If 7 call a method that displays the quadrant of point 1.

// If 8 call a method that displays the quadrant of point 2.

}

System.out.println("Thank you for using my coordinate program.  Good bye.");
}
``````

}

1个回答

userChoice = in.nextInt();

switch (userChoice)
{
case 1:

break;
case 2:
...
}

Java学习的正确打开方式

【图解算法面试】记一次面试：说说游戏中的敏感词过滤是如何实现的？

OpenCV-Python 绘图功能 | 七

GitHub 标星 1.6w+，我发现了一个宝藏项目，作为编程新手有福了！

Java知识体系最强总结(2020版)

Windows可谓是大多数人的生产力工具，集娱乐办公于一体，虽然在程序员这个群体中都说苹果是信仰，但是大部分不都是从Windows过来的，而且现在依然有很多的程序员用Windows。 所以，今天我就把我私藏的Windows必装的软件分享给大家，如果有一个你没有用过甚至没有听过，那你就赚了????，这可都是提升你幸福感的高效率生产力工具哦！ 走起！???? NO、1 ScreenToGif 屏幕，摄像头和白板...

Fiddler+夜神模拟器进行APP抓包

CPU对每个程序员来说，是个既熟悉又陌生的东西？ 如果你只知道CPU是中央处理器的话，那可能对你并没有什么用，那么作为程序员的我们，必须要搞懂的就是CPU这家伙是如何运行的，尤其要搞懂它里面的寄存器是怎么一回事，因为这将让你从底层明白程序的运行机制。 随我一起，来好好认识下CPU这货吧 把CPU掰开来看 对于CPU来说，我们首先就要搞明白它是怎么回事，也就是它的内部构造，当然，CPU那么牛的一个东...

[数据结构与算法] 排序算法之归并排序与基数排序

B 站上有哪些很好的学习资源?

CSS操作之你不得不知的一些小技巧（一）ヾ(Ő∀Ő๑)ﾉ太棒了！！

Java第二周学习
Java第二周学习 1. 数组 1.1 定义数组格式 数据类型[] 数组名 = new 数据类型[容量]; int[] arr = new int[10]; 赋值左侧 数据类型: 告知编译器，当前数组中能够保存的数据类型到底是什么？并且在确定数据类型之后，整个数组中保存的数据类型无法修改！！！ []: 告知编译器这里定义的是一个数组类型数据。 明确告知编译器，数组名是一个【引用数据类型...

​人工智能如何拦截来自太空的古老电波信号？

Java基础知识面试题（2020最新版）

Spring面试题（2020最新版）

C语言写个贪吃蛇游戏

Python入门——四大容器解析

Python3怎么处理Excel中的数据（xlrd、xlwt的使用方法）