UNA HERMOSA MOTO

UNA HERMOSA MOTO

miércoles, 22 de abril de 2015

Problema Propuesto 05



05.-PORCENTAJE DE CADA NÚMERO EN FUNCIÓN A LA SUMA DE 04 NÚMEROS.

Resultado de imagen para porcentaje

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)  throws IOException {
       
        int a=1, b=2, c=3, d=4; 
        int s=a+b+c+d;         
     

double porcentaje_a=(double)(a*100)/s;      
double porcentaje_b=(double)(b*100)/s;      
double porcentaje_c=(double)(c*100)/s;
double porcentaje_d=(double)(d*100)/s;

    
 System.out.println("");
 System.out.println("La variable \"a\" representa el: "+porcentaje_a+"% de "+s);
 System.out.println("La variable \"b\" representa el: "+porcentaje_b+"% de "+s);
 System.out.println("La variable \"c\" representa el: "+porcentaje_c+"% de "+s);
 System.out.println("La variable \"d\" representa el: "+porcentaje_d+"% de "+s);
 // TODO code application logic here
    }

}

No hay comentarios:

Publicar un comentario