﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-Java Home-随笔分类-JAVA代码研读</title><link>http://www.blogjava.net/yemoo/category/12202.html</link><description>Java技术修炼中...</description><language>zh-cn</language><lastBuildDate>Fri, 02 Mar 2007 01:56:06 GMT</lastBuildDate><pubDate>Fri, 02 Mar 2007 01:56:06 GMT</pubDate><ttl>60</ttl><item><title>根据用户输入判断百分制成绩对应等级</title><link>http://www.blogjava.net/yemoo/archive/2006/07/10/57414.html</link><dc:creator>Yemoo'S Java Blog</dc:creator><author>Yemoo'S Java Blog</author><pubDate>Sun, 09 Jul 2006 17:22:00 GMT</pubDate><guid>http://www.blogjava.net/yemoo/archive/2006/07/10/57414.html</guid><wfw:comment>http://www.blogjava.net/yemoo/comments/57414.html</wfw:comment><comments>http://www.blogjava.net/yemoo/archive/2006/07/10/57414.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/yemoo/comments/commentRss/57414.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/yemoo/services/trackbacks/57414.html</trackback:ping><description><![CDATA[
		<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee">
				<span style="COLOR: #0000ff">import</span>
				<span style="COLOR: #000000"> java.io.</span>
				<span style="COLOR: #000000">*</span>
				<span style="COLOR: #000000">;<br /><br /></span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">class</span>
				<span style="COLOR: #000000"> GradeLevel{<br />    </span>
				<span style="COLOR: #0000ff">public</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">static</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #0000ff">void</span>
				<span style="COLOR: #000000"> main(String args[]) </span>
				<span style="COLOR: #0000ff">throws</span>
				<span style="COLOR: #000000"> IOException{<br />        BufferedReader keyin</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> BufferedReader(</span>
				<span style="COLOR: #0000ff">new</span>
				<span style="COLOR: #000000"> InputStreamReader(System.in));<br />        String x;<br />        </span>
				<span style="COLOR: #0000ff">int</span>
				<span style="COLOR: #000000"> y,n;<br />        System.out.println(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">请输入一个成绩:</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />        x</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">keyin.readLine();    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">读取一个字符串</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">        y</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">Integer.parseInt(x);    </span>
				<span style="COLOR: #008000">//</span>
				<span style="COLOR: #008000">将输入的字符串x转换成整型数据y</span>
				<span style="COLOR: #008000">
						<br />
				</span>
				<span style="COLOR: #000000">        n</span>
				<span style="COLOR: #000000">=</span>
				<span style="COLOR: #000000">(</span>
				<span style="COLOR: #000000">99</span>
				<span style="COLOR: #000000">-</span>
				<span style="COLOR: #000000">y)</span>
				<span style="COLOR: #000000">/</span>
				<span style="COLOR: #000000">10</span>
				<span style="COLOR: #000000">+</span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">;<br />        <br />        </span>
				<span style="COLOR: #0000ff">switch</span>
				<span style="COLOR: #000000">(n){<br />            </span>
				<span style="COLOR: #0000ff">case</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">1</span>
				<span style="COLOR: #000000">:System.out.println(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">A</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);</span>
				<span style="COLOR: #0000ff">break</span>
				<span style="COLOR: #000000">;<br />            </span>
				<span style="COLOR: #0000ff">case</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">2</span>
				<span style="COLOR: #000000">:System.out.println(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">B</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);</span>
				<span style="COLOR: #0000ff">break</span>
				<span style="COLOR: #000000">;<br />            </span>
				<span style="COLOR: #0000ff">case</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">3</span>
				<span style="COLOR: #000000">:System.out.println(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">C</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);</span>
				<span style="COLOR: #0000ff">break</span>
				<span style="COLOR: #000000">;<br />            </span>
				<span style="COLOR: #0000ff">case</span>
				<span style="COLOR: #000000"> </span>
				<span style="COLOR: #000000">4</span>
				<span style="COLOR: #000000">:System.out.println(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">D</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);</span>
				<span style="COLOR: #0000ff">break</span>
				<span style="COLOR: #000000">;<br />            </span>
				<span style="COLOR: #0000ff">default</span>
				<span style="COLOR: #000000">:System.out.println(</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">不及格</span>
				<span style="COLOR: #000000">"</span>
				<span style="COLOR: #000000">);<br />        }<br />    }<br />}</span>
		</div>
		<br />要注意以下两个问题:<br />1,建立输入流的类名:BufferedReader而不是BufferReader,不要少写了ed.然后在BufferedReadereizhong建立InputStreamReader类.最后可以调用system.in的realLine方法读入一行数据.<br />2,将百分制转换成与1.2.3.4与其他等5种情况的简单公式:(99-y)/10+1;<img src ="http://www.blogjava.net/yemoo/aggbug/57414.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/yemoo/" target="_blank">Yemoo'S Java Blog</a> 2006-07-10 01:22 <a href="http://www.blogjava.net/yemoo/archive/2006/07/10/57414.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>