Topic: 请问一个程序的问题...谢谢

  Print this page

1.请问一个程序的问题...谢谢 Copy to clipboard
Posted by: dennyworld
Posted on: 2006-07-24 11:01

import java.io.*;
public class ScoreDegree
{
public static void main (String args[])throws IOException
{
InputStreamReader stdin=new InputStreamReader(System.in);
BufferedReader bufin=new BufferedReader(stdin);
int f;
char c='w';
System.out.print("please input f:");
f=Integer.parseInt( bufin.readLine());
if (f>=90&&f<=100)c='A';
if (f>=80&&f<=90) c='B';
if (f>=70&&f<=80) c='C';
if (f>=60&&f<=70) c='D';
if (f>=0 &&f<=60) c='E';
if (f>100||f<0) c='w';
System.out.println("input error");
else
System.out.println("This you are degree: "+c);
stdin.close();
bufin.close();
}
}
问题:
ScoreDegree.java:19: 'else' without 'if'
else
1 error

2.Re:请问一个程序的问题...谢谢 [Re: dennyworld] Copy to clipboard
Posted by: why
Posted on: 2006-07-24 20:59

if (f>100||f<0) {
c='w';
System.out.println("input error");
} else {
System.out.println("This you are degree: "+c);
}

3.Re:请问一个程序的问题...谢谢 [Re: dennyworld] Copy to clipboard
Posted by: balbeleet
Posted on: 2006-07-24 21:30

why真的很厚道,总是看到他很耐心的回答简单问题.代各位菜鸟谢谢你

4.Re:请问一个程序的问题...谢谢 [Re: dennyworld] Copy to clipboard
Posted by: loverkiller
Posted on: 2006-07-25 17:14

可以这样改:
if (f>100||f<0)
{
  c='w';
  System.out.println("input error");
}
加一个大括号就行了

5.Re:请问一个程序的问题...谢谢 [Re: dennyworld] Copy to clipboard
Posted by: leange
Posted on: 2006-07-26 22:14

呵呵……
可以直接将if后面的c='W'删除啊!
直接改成!!!

import java.io.*;
public class ScoreDegree
{
public static void main (String args[])throws IOException
{
InputStreamReader stdin=new InputStreamReader(System.in);
BufferedReader bufin=new BufferedReader(stdin);
int f;
char c='w';
System.out.print("please input f:");
f=Integer.parseInt( bufin.readLine());
if (f>=90&&f<=100)c='A';
if (f>=80&&f<=90) c='B';
if (f>=70&&f<=80) c='C';
if (f>=60&&f<=70) c='D';
if (f>=0 &&f<=60) c='E';
if (f>100||f<0)
System.out.println("input error");
else
System.out.println("This you are degree: "+c);
stdin.close();
bufin.close();
}
}

6.Re:请问一个程序的问题...谢谢 [Re: dennyworld] Copy to clipboard
Posted by: dennyworld
Posted on: 2006-07-28 02:35

谢谢各位大哥对小弟的爱戴.帮的忙啊....我是菜菜鸟..才看了java几天....希望以后各位大哥还得帮帮忙,,,我还要向你们多多学习... 谢谢...麻烦了.....


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923