[go: up one dir, main page]

0% found this document useful (0 votes)
4 views5 pages

Problema 1

Uploaded by

Michael Candia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views5 pages

Problema 1

Uploaded by

Michael Candia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PROBLEMA 1:

package main;

import java.util.Arrays;

class Precio1 {

protected double precio;

public Precio1(double precio) {

this.precio = precio;

class NumFactura extends Precio1 {

private String emisor;

private String cliente;

public NumFactura(double precio, String emisor, String cliente) {

super(precio);

this.emisor = emisor;

this.cliente = cliente;

public void imprimirFactura() {

System.out.println("Numero de Factura:");

System.out.println("El Emisor: " + emisor);

System.out.println("El Cliente: " + cliente);


System.out.println("El Precio es: " + precio);

final class Math2 {

public static double max(double[] nums) {

double max = Double.MIN_VALUE;

for (double num : nums) {

if (num > max) {

max = num;

return max;

public static double min(double[] nums) {

double min = Double.MAX_VALUE;

for (double num : nums) {

if (num < min) {

min = num;

return min;

public static double sum(double[] nums) {

double sum = 0;

for (double num : nums) {


sum += num;

return sum;

public static double average(double[] nums) {

return sum(nums) / nums.length;

public static double geometricMean(double[] nums) {

double product = 1;

for (double num : nums) {

product *= num;

return Math.pow(product, 1.0 / nums.length);

public class Main {

public static void main(String[] args) {

NumFactura factura = new NumFactura(100.0, "Emisor 1", "Cliente 1");

factura.imprimirFactura();

double[] numbers = {1.5, 2.4, 1.8, 4.1, 3};

System.out.println("El Maximo es: " + Math2.max(numbers));

System.out.println("El Minínimo es: " + Math2.min(numbers));


System.out.println("La Sumatorio es : " + Math2.sum(numbers));

System.out.println("La Media aritmética es: " + Math2.average(numbers));

System.out.println("La Media geométrica es: " + Math2.geometricMean(numbers));

Number[] x = new Number[4];

x[0] = new Integer(10);

x[1] = new Float(3.14);

x[2] = new Double(2.71828);

x[3] = new Byte((byte) 5);

System.out.println(Arrays.toString(x));

You might also like