Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedWriter;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.text.DecimalFormat;
- public class exercise6 {
- public static void main(String[] args) throws IOException {
- // TODO Auto-generated method stub
- {
- writefile(69,"c:\\masi\\masiii.txt");
- }
- }
- private static void writefile(int n, String filename)throws IOException {
- // TODO Auto-generated method stub
- FileWriter writehandle = new FileWriter(filename);
- DecimalFormat decimalformat = new DecimalFormat();
- String st, formatted;
- for(int i = 1;i<=n;i++)
- {
- //decimalformat.setMinimumFractionDigits(i);
- //decimalformat.setMinimumFractionDigits(i);
- double x = Math.sqrt(i);
- st="%."+Integer.toString(i)+"f";
- formatted = String.format(st, x);
- //formatted = String.format("%.2f" x);
- writehandle.write(formatted + "\n");
- }
- writehandle.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement