4
五月

程式設計二程式 05/04: 期中考

   Posted by: admin   in 103(下)程式設計(二)

import java.io.*;
//Mid1a
		int a, b, c, all;
		a = Integer.parseInt(args[0]);
		all = a * 5 + b * 2 + c;
		System.out.printf("input=(%d, %d, %d) ans = %d", a, b, c, all);
//Mid1b
import java.io.*;
public class Mid1b {
 
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try{
			FileWriter writer = new FileWriter("package.txt");
			PrintWriter pw = new PrintWriter(writer);
            int largeCount = 1000/5;
			for (int i=largeCount;  i>=0;  i--)
			{
				int j = (1000 - 5 * i)/2;
				System.out.printf("Large= %3d Small = %3d\n" , i, j);
				pw.printf("Large= %3d Small = %3d" , i, j);pw.println();
			} 
			pw.close();
 
		}
		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 星期一, 五月 4th, 2015 at 10:39:50 and is filed under 103(下)程式設計(二). 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.

Leave a reply

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