All pastes #1557845 Raw Edit

Harmiston

public java v1 · immutable
#1557845 ·published 2009-09-08 00:24 UTC
rendered paste body
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package trabalho2parcelas;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.text.DateFormat;import java.text.DecimalFormat;import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;import java.util.GregorianCalendar;/** * * @author userlab1 */public class Main {        /**     * @param args the command line arguments     */    @SuppressWarnings("empty-statement")    public static void main(String[] args) throws IOException, ParseException     {        double valorProduto,calculoParcela = 0;        int parcela, contador =0;        Date dataUm;        String formatado,formatado2,resultado= "";         BufferedReader READER = new BufferedReader(new InputStreamReader (System.in));         DateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");         DecimalFormat nf = new DecimalFormat(" R$ ###,##0.00");          try                        {                                               System.out.println("Entre com o Valor da venda: ");            valorProduto = Double.parseDouble(READER.readLine());            System.out.println("Entre com Quantidade Parcelas: ");            parcela = Integer.parseInt(READER.readLine());            System.out.println("Entre com a Data do Primeiro Vencimento");            dataUm = (Date)formatter.parse(READER.readLine());            Calendar dataVencimento = GregorianCalendar.getInstance();            dataVencimento.setTime(dataUm);                       calculoParcela= valorProduto/parcela;            formatado = nf.format(valorProduto);            formatado2 = nf.format(calculoParcela);            do            {            contador=+1;            dataVencimento.add( Calendar.DAY_OF_MONTH,+30 );            dataUm = dataVencimento.getTime();            resultado = ("Parcela: "+contador+" - Data de Vencimento: "+dataUm+" - Valor da Parcela:"+formatado2+" - Valor Total:"+formatado+"\n");            parcela=-1;            }while(parcela==0);            System.out.println(resultado);        }catch(Exception ex)   {                 System.out.println("Erro na data digitada - "+ex.getMessage ());}                                            // TODO code application logic here    }}