0% found this document useful (0 votes)
28 views13 pages

Universidad Nacional de Ingeniería

The document is a student report from Universidad Nacional de Ingeniería that includes solutions to 3 programming problems. The first problem uses the Newton's method to find the root of a function. The second problem calculates the average grades of students across terms and subjects. The third problem removes a specified letter from an input character array.

Uploaded by

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

Universidad Nacional de Ingeniería

The document is a student report from Universidad Nacional de Ingeniería that includes solutions to 3 programming problems. The first problem uses the Newton's method to find the root of a function. The second problem calculates the average grades of students across terms and subjects. The third problem removes a specified letter from an input character array.

Uploaded by

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

Universidad Nacional de Ingeniería

APELLIDO:SONCCO VELIZ
NOMBRE:GERSON JOSSEPH
Codigo:20171486J
Curso: Programación Digital
Código Curso: MA713 sección: N
AÑO:

2018
Problema 1:

package metodonewton;

import java.util.Scanner;

import java.math.*;

public class Metodonewton {

double numero,n;

public static Scanner entrada =new Scanner(System.in);

public static double funcionDada(double x){

return Math.cos(x)-Math.pow(x,3);

public static double derivadafuncionDada(double x){

return -Math.sin(x)-(3*x*x);

public static double nDatos(double n){

Scanner entrada =new Scanner(System.in);

System.out.println("adad");

n=entrada.nextDouble();

return n;

public double Metodo(double x){

int i=0;
do{

numero=x;

x=x-funcionDada(x)/derivadafuncionDada(x);

n=Math.abs((x-numero)/x);

System.out.println(" x "+i+" = "+x+" error "+"="+n+"\n");

i=i+1;

}while(x!=numero && i<100);

if(i==100)

System.out.println("no converge");

else

System.out.println("solucion "+x);

return x;

public static void main(String[] args) {

// TODO code application logic here

Metodonewton objeto =new Metodonewton();

double x;

System.out.println("Ingresar el dato");

x=entrada.nextDouble();

objeto.Metodo(x);

Respuesta:

Ingresar el dato
4

x 0 = 2.6314718936108763 error =0.5200618367659039

x 1 = 1.7334143810361353 error =0.5180858785987076

x 2 = 1.1964335167172515 error =0.44881797176013616

x 3 = 0.9386472702053927 error =0.27463590924357617

x 4 = 0.8702044139095224 error =0.07865146993265713

x 5 = 0.8654956180263444 error =0.0054405773814497045

x 6 = 0.865474033553886 error =2.4939480124953138E-5

x 7 = 0.8654740331016144 error =5.225709105572314E-10

x 8 = 0.8654740331016144 error =0.0

solucion 0.8654740331016144
Metodonewton
Problema 2:

package problema2;

import java.util.Scanner;

public class Problema2 {

int [][]cargar (int matriz[][]){

for (int i = 0; i < 3; i++) {

Scanner entrada=new Scanner(System.in);

for (int j = 0; j < 5; j++) {

System.out.print("nota del "+(i+1)+ " trimestre del alumno "+ (j+1)+":");

matriz[i][j]=entrada.nextInt();

return matriz;

double [] medtri(int matriz[][]){

double medtri[]=new double [3];

for (int i = 0; i < 3; i++) {

for (int j = 0; j < 5; j++) {

medtri[i]= medtri[i]+ matriz[i][j];

medtri[i]= medtri[i]/5;

return medtri;

double [] medal(int matriz[][]){


double medal[]=new double [5];

for (int i = 0; i <5; i++) {

for (int j = 0; j < 3; j++) {

medal[i]=medal[i]+matriz[j][i];

medal[i]= medal[i]/3;

return medal;

public static void main(String[] args) {

Scanner entrada=new Scanner(System.in);

Problema2 obj=new Problema2();

double medtri[]=new double [3];

int matriz[][]=new int [3][5];

double medal[]=new double [5];

matriz=obj.cargar(matriz);

medtri=obj.medtri(matriz);

medal=obj.medal(matriz);

System.out.println(" p1 p2 p3 p4 p5 promedio");

for (int i = 0; i < 3; i++) {

System.out.print((i+1)+"Trimestre ");

for (int j = 0; j < 5; j++) {

System.out.print(matriz[i][j]+" ");

System.out.print("" +medtri[i]);

System.out.println("");

System.out.print("promedio ");
for (int i = 0; i < 5; i++) {

System.out.printf("%.2f ",medal[i]);

Respuesta:
nota del 1 trimestre del alumno 1:14

nota del 1 trimestre del alumno 2:12

nota del 1 trimestre del alumno 3:14

nota del 1 trimestre del alumno 4:15

nota del 1 trimestre del alumno 5:11

nota del 2 trimestre del alumno 1:10

nota del 2 trimestre del alumno 2:14

nota del 2 trimestre del alumno 3:12

nota del 2 trimestre del alumno 4:14

nota del 2 trimestre del alumno 5:15

nota del 3 trimestre del alumno 1:12

nota del 3 trimestre del alumno 2:13

nota del 3 trimestre del alumno 3:14

nota del 3 trimestre del alumno 4:15

nota del 3 trimestre del alumno 5:12

p1 p2 p3 p4 p5 promedio

1Trimestre 14 12 14 15 11 13.2

2Trimestre 10 14 12 14 15 13.0

3Trimestre 12 13 14 15 12 13.2

promedio 12,00 13,00 13,33 14,67 12,67


Problema2
Problema 3:
package metodos4;

import java.util.Scanner;

public class problema3 {

public char []cargar(int n){

Scanner entrada=new Scanner(System.in);

char letras[]=new char [n];

for (int i = 0; i < letras.length; i++) {

System.out.print("digite una letra :");

letras[i]=entrada.next().charAt(0);

return letras;

public char leerletra() {

Scanner entrada=new Scanner(System.in);

System.out.println("que letra desea eleminar");

char eliminar=entrada.next().charAt(0);

return eliminar;

public char[]retornar(char letras[],char eliminar ){

Scanner entrada=new Scanner(System.in);

int c=0;int k=0;

for (int i = 0; i < letras.length; i++) {

if(eliminar!=letras[i]){

c++;

}
}

char letras2[]=new char [c];

for (int i = 0; i < letras.length; i++) {

if(eliminar!=letras[i]){

letras2[k]=letras[i];

k++;

return letras2;

public static void main(String[] args) {

problema3 obj=new problema3();

Scanner entrada=new Scanner(System.in);

System.out.println("cuantos elementos desea que tenga el arreglo");

int n=entrada.nextInt();

char letras[] =obj.cargar(n);

char eliminar=obj.leerletra();

char letras2[]=obj.retornar(letras, eliminar);

System.out.println("arreglo letra eliminada Resultado Final ") ;

for (int i = 0; i < letras.length; i++) {

System.out.print(letras[i]+",");

System.out.print(" "+eliminar +" ");

for (int i = 0; i < letras2.length; i++) {

System.out.print(letras2[i] +",");

}
Respuesta:
cuantos elementos desea que tenga el arreglo

digite una letra :h

digite una letra :g

digite una letra :h

digite una letra :e

digite una letra :r

que letra desea eleminar

arreglo letra eliminada Resultado Final

h,g,h,e,r, h g,e,r,

Metodos4

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy