跪求1个JAVA程序代码

来源:百度知道 编辑:UC知道 时间:2024/04/28 03:44:05
写一道程序,告诉用户输入A会显示一个正三角,输入B会显示倒三角,输入其他显示OK
正反三角代码我已经写完了,请哪个高手帮我写上面我要求的,并告诉我,我那2个三角的代码应该插入在哪段代码后面,并简单说下每段代码有什么用,小弟感激不尽,谢谢!

while(true){
// prompt the user to enter their name
System.out.print("Enter your instruction: ");

// open up standard input
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

String userInstrucation = null;

// read the username from the command-line; need to use try/catch with the
// readLine() method
try {
userInstrucation = br.readLine();
if(userInstrucation .equals("A")){
//////////////////////////draw you triangle
}else if(userInstrucation .equals("B")){
/////////////////////////draw you rotated triangle
}else if(userInstrucation.equals("quit")){
System.exit(1);
}
else{
System.out.println("OK")
}
} catch (IOException ioe) {
System.out.println("IO error trying to read your name!");
Sys