UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 22 de abril de 2015

Problema Propuesto 17



17.- DADO UN SALDO ANTERIOR. TIPO DE MOVIMIENTO R(RETIRO) O D(DEPOSITO) Y MONTO DE LA TRANSACCION, OBTENER COMO DATO DE SALIDA EL SALDO ACTUAL.


Resultado de imagen para SALDO

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package propuesto017;
import java.util.Scanner;
/**
 *
 * @author abel montalvan
 */
public class PROPUESTO017 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
    int sal_ant, monto, sal_actual=0;
    char tipo_mov;
    
    
            Scanner teclado = new Scanner(System.in);
            System.out.print("Ingresar el Saldo: ");
            sal_ant=teclado.nextInt();
            System.out.print("Ingresar el Tipo de Movimiento: ");
            tipo_mov = teclado.next().charAt(0);
            System.out.print("Ingresar el Monto: ");
            monto=teclado.nextInt();
            
            if(tipo_mov=='R'){
                  sal_actual = sal_ant - monto;
            }
            else
            {
                  if(tipo_mov=='D'){
                   sal_actual = sal_ant + monto;
                  }
            }
            
            System.out.println("");
            System.out.print("El saldo actual es: "+sal_actual);
            System.out.println();       
    }
      }

No hay comentarios:

Publicar un comentario