哪位高手帮忙用JAVA编个程序吧,不胜感激~
从键盘输入的字符‘A’,‘B’,‘C’或‘D’。如果输入‘A’,显示‘Ais85~100’;如果输入‘B’,显示‘Bis70~84’;如果输入‘C’,显示‘Cis60~6...
从键盘输入的字符‘A’,‘B’,‘C’或‘D’。如果输入‘A’,
显示‘A is 85~100’;如果输入‘B’,显示‘B is 70~84’;如果输入‘C’,显示‘C is 60~69’;如果输入‘D’,显示‘D is<60’;如果输入其他字符,显示‘输入错误’ 展开
显示‘A is 85~100’;如果输入‘B’,显示‘B is 70~84’;如果输入‘C’,显示‘C is 60~69’;如果输入‘D’,显示‘D is<60’;如果输入其他字符,显示‘输入错误’ 展开
展开全部
public void test1() throws IOException{
System.out.println("请输入");
InputStream in = System.in;
while(true){
char c = (char) in.read();
if(c=='A'){
System.out.println("A is 85~100");
in.read();
in.read();
}else if(c=='B'){
System.out.println("B is 70~84");
in.read();
in.read();
}else if(c=='C'){
System.out.println("C is 60~69");
in.read();
in.read();
}else if(c=='D'){
System.out.println("D is<60");
in.read();
in.read();
}else{
System.out.println("输入错误");
in.read();
in.read();
}
}
}
public void test2() throws IOException{
System.out.println("请输入");
InputStream in = System.in;
while(true){
int a= in.read();
switch(a){
case 65:System.out.println("A is 85~100");in.read();in.read();break;
case 66:System.out.println("B is 70~84");in.read();in.read();break;
case 67:System.out.println("C is 60~69");in.read();in.read();break;
case 68:System.out.println("D is<60");in.read();in.read();break;
default:System.out.println("输入错误");in.read();in.read();
}
}
}
System.out.println("请输入");
InputStream in = System.in;
while(true){
char c = (char) in.read();
if(c=='A'){
System.out.println("A is 85~100");
in.read();
in.read();
}else if(c=='B'){
System.out.println("B is 70~84");
in.read();
in.read();
}else if(c=='C'){
System.out.println("C is 60~69");
in.read();
in.read();
}else if(c=='D'){
System.out.println("D is<60");
in.read();
in.read();
}else{
System.out.println("输入错误");
in.read();
in.read();
}
}
}
public void test2() throws IOException{
System.out.println("请输入");
InputStream in = System.in;
while(true){
int a= in.read();
switch(a){
case 65:System.out.println("A is 85~100");in.read();in.read();break;
case 66:System.out.println("B is 70~84");in.read();in.read();break;
case 67:System.out.println("C is 60~69");in.read();in.read();break;
case 68:System.out.println("D is<60");in.read();in.read();break;
default:System.out.println("输入错误");in.read();in.read();
}
}
}
展开全部
public void test(String str){
if(str=="A"){
System.out.println("A is 85-100");
}else if(str=="B") {
System.out.println("A is 70-84");
}else if(str=="C"){
System.out.println("C is 60-69");
}else{
System.out.println("error!");
}
}
if(str=="A"){
System.out.println("A is 85-100");
}else if(str=="B") {
System.out.println("A is 70-84");
}else if(str=="C"){
System.out.println("C is 60-69");
}else{
System.out.println("error!");
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class sadf12{
MyWindow ck = null;
String str="";
sadf12(){
ck = new MyWindow();
ck.setSize(320,240);
ck.setVisible(true);
}
class MyWindow extends JFrame{
MyPanel mb = null;
MyKey jp = null;
MyWindow(){
jp = new MyKey();
mb = new MyPanel();
this.add(mb);
this.addKeyListener(jp);
this.repaint();
}
class MyKey implements KeyListener{
public void keyPressed(KeyEvent e){
switch (e.getKeyCode()){
case KeyEvent.VK_A://A
System.out.println(str);
str="A is 85~100";
break;
case KeyEvent.VK_B://B
System.out.println(str);
str="B is 70~84";
break;
case KeyEvent.VK_C://C
System.out.println(str);
str="C is 60~69";
break;
case KeyEvent.VK_D://D
System.out.println(str);
str="D is < 60";
break;
}
repaint();
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
}
class MyPanel extends JPanel{
public void paint(Graphics g){
g.setColor(Color.RED);
g.drawString(str, 100, 100);
}
}
}
public static void main(String[] args){
new sadf12();
}
}
这个是个窗口程序 直接在键盘上按ABCD就会显示你想要的结果
import java.awt.Graphics;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class sadf12{
MyWindow ck = null;
String str="";
sadf12(){
ck = new MyWindow();
ck.setSize(320,240);
ck.setVisible(true);
}
class MyWindow extends JFrame{
MyPanel mb = null;
MyKey jp = null;
MyWindow(){
jp = new MyKey();
mb = new MyPanel();
this.add(mb);
this.addKeyListener(jp);
this.repaint();
}
class MyKey implements KeyListener{
public void keyPressed(KeyEvent e){
switch (e.getKeyCode()){
case KeyEvent.VK_A://A
System.out.println(str);
str="A is 85~100";
break;
case KeyEvent.VK_B://B
System.out.println(str);
str="B is 70~84";
break;
case KeyEvent.VK_C://C
System.out.println(str);
str="C is 60~69";
break;
case KeyEvent.VK_D://D
System.out.println(str);
str="D is < 60";
break;
}
repaint();
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
}
class MyPanel extends JPanel{
public void paint(Graphics g){
g.setColor(Color.RED);
g.drawString(str, 100, 100);
}
}
}
public static void main(String[] args){
new sadf12();
}
}
这个是个窗口程序 直接在键盘上按ABCD就会显示你想要的结果
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这么简单自己想!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"">
<html xmlns="">
<head>
<title>Untitled</title>
</head>
<body>
<script language="JavaScript">
var NowDate=new Date();
s="Today is:";
s += NowDate.getYear() + "-";
s += NowDate.getMonth() + 1 + "-";
s += NowDate.getDate() + " ";
switch(NowDate.getDay())
{
case 0:
s += "Sunday";
break;
case 1:
s += "Monday";
break;
case 2:
s += "Tuesday";
break;
case 3:
s += "Wednesday";
break;
case 4:
s += "Thursday";
break;
case 5:
s += "Friday";
break;
case 6:
s += "Saturday";
break;
default:
break;
}
document.write(s);
</script>
</body>
</html>
"">
<html xmlns="">
<head>
<title>Untitled</title>
</head>
<body>
<script language="JavaScript">
var NowDate=new Date();
s="Today is:";
s += NowDate.getYear() + "-";
s += NowDate.getMonth() + 1 + "-";
s += NowDate.getDate() + " ";
switch(NowDate.getDay())
{
case 0:
s += "Sunday";
break;
case 1:
s += "Monday";
break;
case 2:
s += "Tuesday";
break;
case 3:
s += "Wednesday";
break;
case 4:
s += "Thursday";
break;
case 5:
s += "Friday";
break;
case 6:
s += "Saturday";
break;
default:
break;
}
document.write(s);
</script>
</body>
</html>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询