Five - { System.out.print("How many days? ");...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
/** Five class *<Doubles a persons pay * for the amount of days * entered and writes to a * .txt file> *@author Jeff Cox */ * import java.util.Scanner; import java.io.*; import java.text.DecimalFormat; public class Five { public static void main(String[] args) throws IOException { int days = 0; double total = .01; DecimalFormat Currency = new DecimalFormat("#0.00"); Scanner keyboard = new Scanner(System.in); while (days<1)
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { System.out.print("How many days? "); days = keyboard.nextInt(); } PrintWriter outputFile = new PrintWriter("Total.txt"); outputFile.println("$"+0.01); for (int i = 1; i < days; i++) { total = total + (Math.pow(2,i)/100); outputFile.println("$"+Currency.format(Math.pow(2,i)/100)); } outputFile.println("Total: $"+ Currency.format(total)); outputFile.close(); } }...
View Full Document

This note was uploaded on 07/28/2009 for the course JAVA 1 taught by Professor M during the Spring '09 term at Anne Arundel CC.

Ask a homework question - tutors are online