import java.io.*;
public class FinalClass {
 
	public static void main(String[] args) {
		try
		{
			//In
			FileReader reader = new FileReader("math.txt");
			BufferedReader sr = new BufferedReader(reader);
			//Out
			FileWriter writer = new FileWriter(result.txt);
			PrintWriter pw = new PrintWriter(writer);
 
			String line = sr.readLine();
			double sum = 0.0, avg=0.0;
			int count = 0;
			while (line != null && line.length() > 0)
			{
				int score = Integer.parseInt(line);
				double modified; 
				if (score >=60)
					modified = 20.0 + score;
				else
					modified = 0.5 *(score)+ 30; 
				sum += modified; count++;
				System.out.printf("%2d => %5.2f\n", score, modified);
				        pw.printf("%5.2f", modified);pw.println()
				line = sr.readLine();
			}
			sr.close();		
			pw.close();
			if (count > 0)//計算平均
				avg = sum / count;
			System.out.printf("Average = %5.2f", avg)
		}
		catch(FileNotFoundException fe)
		{
			System.out.printf(fe.getMessage());
		}
		catch(IOException ie)
		{
			System.out.printf(ie.getMessage());
		}
	}
}

bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark

Tags: , , ,

This entry was posted on 星期二, 六月 17th, 2014 at 11:35:21 and is filed under 102(下)程式設計(二). You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

7 Trackbacks/Pings

  1. Elmer    八月 22 2014 / 10下午:

    streams@readiness.circonscriptions” rel=”nofollow”>.…

    спс за инфу….

  2. Herman    八月 23 2014 / 7上午:

    nagel@snaked.transposition” rel=”nofollow”>.…

    tnx!…

  3. Marion    八月 24 2014 / 7上午:

    prosodic@takings.tornadoes” rel=”nofollow”>.…

    tnx for info….

  4. daniel    十二月 11 2014 / 11上午:

    appraisingly@representatives.startlingly” rel=”nofollow”>.…

    ñýíêñ çà èíôó!!…

  5. Alfred    一月 15 2015 / 6上午:

    kali@watered.codetermines” rel=”nofollow”>.…

    ñïñ!…

  6. lester    一月 15 2015 / 7上午:

    peculiarity@max.grassy” rel=”nofollow”>.…

    tnx!!…

  7. max    一月 15 2015 / 7上午:

    francis@buncha.marenzio” rel=”nofollow”>.…

    good….

Leave a reply

Name (*)
Mail (will not be published) (*)
URI
Comment